Wear leveling method and system for solid state disk, electronic equipment and medium

By obtaining access characteristic data of each data block of solid state hard disk, distinguishing read priority blocks and write priority blocks, and performing data migration, the problem of insufficient wear equalization accuracy in the prior art is solved, and more accurate wear equalization control is achieved.

CN120029555AActive Publication Date: 2025-05-23SHENZHEN XINGYAO SEMICON CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510496818.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-05-23
Estimated Expiration
2045-04-21

AI Technical Summary

Technical Problem

The wear equalization method of existing solid-state drives is difficult to accurately identify and process wear deviations in data blocks, resulting in insufficient accuracy of wear equalization.

Method used

By obtaining the access characteristic data of each data block in the hard disk area, the read and write ratio of the data blocks in the preset time window is determined, and it is divided into read-first blocks and write-first blocks, and the area to be balanced is identified by calculating the ratio of the number of read-first blocks and write-first blocks in the hard disk area. Then, the write priority block with the most erased times and the read priority block with the least erased times in other areas are selected from the area to be equalized, and data migration is performed to achieve wear equalization.

Benefits of technology

This method accurately identifies the access behavior characteristics and wear conditions of data blocks, and realizes precise positioning of wear unbalanced areas and wear balance between data blocks, which significantly improves the accuracy of wear equalization of solid-state hard disks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029555A_ABST
    Figure CN120029555A_ABST
Patent Text Reader

Abstract

The invention discloses a solid state disk wear leveling method and system, electronic equipment and a medium, and relates to the technical field of data processing. The method comprises the following steps: acquiring access feature data of each data block in a plurality of hard disk regions; based on the access feature data of each data block, determining a read-write proportion of the corresponding data block in a preset time window, and determining the corresponding data block as a read priority block or a write priority block according to each read-write proportion; obtaining a quantity ratio of read priority blocks to write priority blocks in each hard disk region, and when the quantity ratio of any hard disk region exceeds a preset ratio range, determining the corresponding hard disk region as a to-be-balanced region; selecting a write priority block with the most erasing times from the to-be-balanced area as a first target block, and selecting a read priority block with the least erasing times from the remaining hard disk area as a second target block; and migrating the data in the first target block to the second target block. By implementing the technical scheme provided by the invention, the effect of improving the wear leveling accuracy of the solid state disk is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and particularly relates to a wear leveling method, system, electronic device and medium for a solid state drive. Background Art

[0002] With the rapid development of information technology, solid state drives (SSDs) have been widely used in personal computers, data centers and other fields due to their advantages such as high-speed read and write performance, low power consumption and shock resistance. Different from traditional mechanical hard disks, the storage units of solid state drives have a limited number of erase and write cycles, and excessive erase and write will cause the storage units to fail. Therefore, wear leveling technology has become a key technology to improve the service life of solid state drives.

[0003] Currently, the wear leveling methods of existing solid state drives mainly record and track the number of erase and write cycles of data blocks, and evenly distribute the data of each data block after analysis to achieve wear leveling of the solid state drive. However, in actual applications, due to the differences in wear conditions of data blocks under different data access behaviors, simply adopting the existing method of evenly distributing data blocks often easily ignores the wear deviation of data blocks, thereby reducing the accuracy of wear leveling of the solid state drive. Summary of the Invention

[0004] This application provides a wear leveling method, system, electronic device and medium for a solid state drive, which has the effect of improving the accuracy of wear leveling of the solid state drive.

[0005] In a first aspect, this application provides a wear leveling method for a solid state drive, including: Obtaining access feature data of each data block in multiple hard disk regions; In each of the hard disk regions, based on the access feature data of each data block, determining the read-write ratio of the corresponding data block within a preset time window, and determining the corresponding data block as a read-priority block or a write-priority block according to each read-write ratio; Obtaining the quantity ratio of read-priority blocks to write-priority blocks in each hard disk region, and when the quantity ratio of any hard disk region exceeds a preset ratio range, determining the corresponding hard disk region as a region to be balanced; Selecting the write-priority block with the most erase and write cycles as the first target block from the region to be balanced, and selecting the read-priority block with the least erase and write cycles from the remaining hard disk regions as the second target block; Migrating the data in the first target block to the second target block.

[0006] In a second aspect of this application, a wear leveling system for a solid state drive is provided, and the system includes: A data acquisition module, configured to obtain access feature data of each data block in multiple hard disk regions; A priority block determination module is used to determine, in each of the hard disk areas, a read-write ratio of a corresponding data block within a preset time window based on access characteristic data of each of the data blocks, and determine the corresponding data block as a read priority block or a write priority block according to each of the read-write ratios; A region determination module, used for obtaining the ratio of the number of read priority blocks to the number of write priority blocks in each hard disk region, and when the ratio of the number of any hard disk region exceeds a preset ratio range, determining the corresponding hard disk region as a region to be balanced; A data migration module is used to select the write priority block with the most erase and write times from the area to be balanced as the first target block, and select the read priority block with the least erase and write times from the remaining hard disk area as the second target block; and migrate the data in the first target block to the second target block.

[0007] In a third aspect of the present application, an electronic device is provided, comprising a memory, a processor, and a program stored in the memory and executable on the processor, wherein the program can implement a wear leveling method for a solid state drive when loaded and executed by the processor.

[0008] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements a wear leveling method for a solid-state hard disk.

[0009] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: By adopting the above technical scheme, by obtaining the access characteristic data of each data block in the hard disk area, and determining the read-write ratio of the data block within a preset time window based on the access characteristic data, the access behavior characteristics of the data block are accurately identified, thereby distinguishing the data block into a read priority block and a write priority block, and effectively distinguishing the usage characteristics of the data block under different data access modes; then, by calculating the ratio of the number of read priority blocks to write priority blocks in the hard disk area, the area to be balanced is identified, and the precise positioning of the area with uneven wear is achieved; then, by selecting the write priority block with the most erase and write times in the area to be balanced as the first target block, and selecting the read priority block with the least erase and write times from other areas as the second target block, the optimal target selection for data migration is ensured; finally, by migrating the data in the first target block to the second target block, the wear balance between the data blocks is achieved on the basis of considering the actual access behavior differences of the data blocks, avoiding the wear deviation problem that may be caused by relying solely on the average distribution method, and effectively balancing the degree of wear between different areas, thereby significantly improving the accuracy of wear leveling of the solid-state hard disk. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Figure 1It is a flowchart of a wear leveling method for a solid state hard disk provided in an embodiment of the present application; Figure 2 It is a structural schematic diagram of a wear leveling system of a solid state drive provided in an embodiment of the present application; Figure 3 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0011] Description of reference numerals: 300, electronic device; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. DETAILED DESCRIPTION

[0012] In order to enable technicians in this field to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.

[0013] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.

[0014] In the description of the embodiments of the present application, the meaning of the term "multiple" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0015] The present application embodiment provides a wear leveling method for a solid state drive. In one embodiment, please refer to Figure 1 , Figure 1 The present invention provides a flow chart of a wear leveling method for a solid-state drive provided by an embodiment of the present invention. The method can be implemented by a computer program, which can be integrated into an application or run as an independent tool application. The method can also be implemented by a single-chip microcomputer or run in a wear leveling system for a solid-state drive based on a von Neumann system. Specifically, the method can include the following steps: Step 101: Obtain access characteristic data of each data block in multiple hard disk areas.

[0016] The hard disk area refers to a storage area with continuous physical addresses divided in the storage space of the solid-state hard disk, which can be understood as a storage unit set composed of multiple adjacent data blocks.

[0017] A data block is the smallest addressable storage unit in each hard disk area of ​​a solid-state drive. Each data block has a unique physical address identifier, and a corresponding relationship is established with the logical address through an address mapping table. As the basic unit for data read and write operations on a solid-state drive, a data block must be erased before data is written, and the erase operation will cause wear and tear on the storage unit.

[0018] Access characteristic data refers to statistical information that reflects the read and write access behaviors of data blocks during actual use.

[0019] Specifically, the solid-state drive divides its storage space into multiple hard disk areas, each of which contains multiple data blocks. In order to accurately grasp the usage status of each data block, it is first necessary to obtain the access feature data of each data block. Specifically, by setting an access monitoring module in the controller of the solid-state drive, the module can record the read and write operations of each data block in real time. When a data block is read or written, the access monitoring module records the operation type, operation timestamp and data block identifier in the access log. The access monitoring module also counts the number of times each data block is read and written within a preset time window (for example, 1 hour, 24 hours, etc.), and stores these statistical data as access feature data of the data block in a specific storage area of ​​the solid-state drive. These access feature data reflect the usage mode of the data block in the actual application scenario, and provide a data basis for the subsequent identification of the access tendency of the data block. By obtaining these access feature data, the actual usage of each data block can be more accurately understood, thereby providing a more accurate basis for subsequent wear leveling decisions, and avoiding the balance error caused by relying solely on the statistics of the number of erases and writes. For example, for a data block that is frequently read but seldom written, even if its cumulative erase count is low, it should be kept in its current location instead of simply being migrated as a target for wear leveling. This access feature-based analysis method can better adapt to data access patterns in different application scenarios and improve the accuracy and efficiency of wear leveling.

[0020] Step 102: In each hard disk area, based on the access characteristic data of each data block, determine the read-write ratio of the corresponding data block within a preset time window, and determine the corresponding data block as a read priority block or a write priority block according to each read-write ratio.

[0021] The read-write ratio refers to the ratio between the read frequency and the write frequency of a data block within a preset time window, which can be understood as a quantitative indicator for measuring the access behavior tendency of a data block.

[0022] A read priority block is a data block with significantly more read operations than write operations within a preset time window, which is specifically manifested as a read-write ratio greater than or equal to the dynamic classification threshold. This type of data block usually stores relatively stable data content, such as operating system files, application files, or user data that is frequently accessed but rarely modified. Since read priority blocks have fewer write operations, the degree of wear of their storage units is relatively low, so they are suitable as the target location for data migration and are used to receive data from write priority blocks.

[0023] Write priority blocks refer to data blocks with relatively frequent write operations within a preset time window, which is specifically manifested as a read-write ratio less than the dynamic classification threshold. Such data blocks are usually used to store frequently updated data content, such as system logs, database files, or temporary cache files. Since write priority blocks frequently write data, the degree of wear of their storage units is relatively high. Wear leveling technology is needed to migrate the data in them to read priority blocks in a timely manner to avoid excessive wear of local storage units, thereby extending the overall service life of the SSD.

[0024] Specifically, in order to accurately identify the access tendency of a data block, it is necessary to analyze and process the acquired access feature data. First, the number of reads and the number of writes of each data block in a preset time window are extracted from the access feature data. Then, based on the number of reads and the duration corresponding to the preset time window, the read frequency of the data block is calculated. Similarly, based on the number of writes and the duration corresponding to the preset time window, the write frequency of the data block is calculated. The ratio between the read frequency and the write frequency of the data block is calculated to obtain the read-write ratio of the data block. For example, if the read frequency of a data block in the past 24 hours is 20 times / hour and the write frequency is 2 times / hour, then its read-write ratio is 10. Next, based on the read-write ratio of each data block in the hard disk area, the concentrated characteristic value of the read-write ratio is calculated. Specifically, first, the arithmetic mean of the read-write ratio of each data block in the area is calculated, and then the deviation value between each read-write ratio and the arithmetic mean is determined, and the arithmetic mean is weightedly corrected based on these deviation values, and the corrected arithmetic mean is determined as the concentrated characteristic value. The dynamic classification threshold is determined based on this concentrated characteristic value. When the read-write ratio of a data block is greater than or equal to the dynamic classification threshold, it is determined as a read priority block, otherwise it is determined as a write priority block. In this way, data blocks can be dynamically classified according to their actual access patterns, avoiding the blindness of balancing based only on the number of erases and writes in traditional methods. This dynamic classification method based on the read-write ratio can more accurately reflect the usage characteristics of data blocks in actual applications, provide a more reasonable decision-making basis for subsequent wear leveling, and thus improve the accuracy and efficiency of wear leveling.

[0025] Based on the above embodiment, as an optional embodiment, in step 102: determining the read-write ratio of the corresponding data block within the preset time window based on the access characteristic data of each data block, this step may also include the following steps: Step 201: extracting the number of reads and writes of the corresponding data block within a preset time window from each access feature data.

[0026] Specifically, the controller of the solid-state drive is provided with an access monitoring module, which maintains an access log table for recording the usage of data blocks. The structure of the access log table contains information such as the data block number, operation type, and operation time. When it is necessary to extract access feature data, the system first determines a preset time window, for example, taking the current time as the end point and calculating forward twenty-four hours as the start point. Subsequently, the system retrieves all access records within this time window. For each data block, the system sets a read counter and a write counter respectively. During the retrieval process, when a read operation is encountered, the read counter of the corresponding data block increases by one count; when a write operation is encountered, the write counter of the corresponding data block increases by one count. In this way, the system can obtain the exact number of reads and writes of each data block within the preset time window, and these data are stored in a special statistical table to prepare for subsequent frequency calculations.

[0027] Step 202: Based on each read count and the duration corresponding to the preset time window, calculate the read frequency of the corresponding data block, and based on each write count and the duration corresponding to the preset time window, calculate the write frequency of the corresponding data block.

[0028] Specifically, first, the system determines the length of the preset time window, such as twenty-four hours. Then, for each data block, the system divides its read count by the length of the time window to obtain the read frequency, and similarly divides the write count by the length of the time window to obtain the write frequency. For example, if a data block is read four hundred and eighty times and written forty-eight times within twenty-four hours, then its read frequency is twenty times per hour and its write frequency is two times per hour. Considering that some data blocks may not have write operations within the preset time window, the system will set a minimum frequency value, such as 0.001 per hour. When the calculated frequency is lower than this value, this minimum frequency value is used instead. This can avoid abnormal situations in subsequent calculations, and can also reflect the characteristics that data blocks are rarely written. The system records the read frequency and write frequency of each data block in the frequency statistics table.

[0029] Step 203: The ratio between the reading frequency and the writing frequency of each data block is used as the reading and writing ratio of the corresponding data block.

[0030] Specifically, the system calculates the read-write ratio that reflects the access characteristics of the data block based on the calculated read frequency and write frequency. Specifically, for each data block, the system divides its read frequency by the write frequency to obtain the read-write ratio of the data block. For example, if the read frequency of a data block is twenty times per hour and the write frequency is two times per hour, then its read-write ratio is ten. For those data blocks whose write frequency is equal to the minimum frequency value, the system will set their read-write ratio to a larger preset value, such as one thousand, to indicate that these data blocks are almost not written. The read-write ratio of all data blocks will be limited to between zero and the preset maximum value to ensure the standardization of the data. Finally, the system saves each data block and its corresponding read-write ratio in a ratio statistics table. This table clearly shows the access tendency of different data blocks and provides an important basis for the subsequent classification of data blocks.

[0031] Based on the above embodiment, as an optional embodiment, in step 102: determining the corresponding data block as a read priority block or a write priority block according to each read-write ratio, this step may also include the following steps: Step 204: Based on the read-write ratio of each data block in the hard disk area, a centralized feature value of the read-write ratio is calculated, and a dynamic classification threshold is determined according to the centralized feature value.

[0032] Specifically, the system needs to calculate the concentrated feature value reflecting the overall access characteristics of the hard disk area based on the obtained read-write ratio data. First, the system obtains the read-write ratio of all data blocks in the hard disk area, adds these read-write ratios and divides them by the total number of data blocks to obtain the arithmetic mean. Next, the system calculates the difference between the read-write ratio of each data block and the arithmetic mean to obtain the deviation value of each data block. Then, the system analyzes these deviation values ​​and regards the deviation values ​​that exceed the preset deviation range as abnormal values. For non-abnormal deviation values, the system calculates the weighted sum of them and the arithmetic mean, where the weight coefficient can be dynamically adjusted according to the size of the deviation value, and the smaller the deviation value, the greater the weight. Finally, the system determines this weighted and corrected arithmetic mean as the concentrated feature value of the hard disk area. Based on this concentrated feature value, the system obtains the dynamic classification threshold by multiplying it by a preset adjustment coefficient. This calculation method not only takes into account the overall distribution characteristics of the read-write ratio of the data block, but also reduces the influence of abnormal data through the weighted correction mechanism, so that the dynamic classification threshold finally obtained can more accurately reflect the actual usage of the hard disk area.

[0033] Based on the above embodiment, as an optional embodiment, in step 204: based on the read-write ratio of each data block in the hard disk area, the centralized characteristic value of the read-write ratio is calculated. This step may also include the following steps: Step 214: Calculate the arithmetic mean of the read-write ratio of each data block in the hard disk area.

[0034] Specifically, the system first obtains the read-write ratio data of all data blocks in the hard disk area. In order to obtain the overall access characteristics, the system accumulates these read-write ratios and then divides them by the total number of data blocks to obtain the arithmetic mean. For example, assuming that there are one thousand data blocks in the hard disk area, the system sums up the read-write ratios of these one thousand data blocks and divides them by one thousand to obtain the initial arithmetic mean reflecting the overall access characteristics. This arithmetic mean preliminarily reflects the average access characteristics of the data blocks in the hard disk area and provides a benchmark value for subsequent deviation analysis. Using the arithmetic mean as the initial calculation result can ensure that the calculation process is simple and intuitive, and at the same time lay the foundation for subsequent refined processing.

[0035] Step 224: Determine the deviation between each read-write ratio and the arithmetic mean.

[0036] Specifically, the system needs to analyze the degree of deviation of the read-write ratio of each data block relative to the arithmetic mean. Specifically, the system calculates the difference between the read-write ratio of each data block and the arithmetic mean one by one to obtain the deviation value of each data block. The system also counts the distribution of positive and negative deviation values, and records the maximum and minimum values ​​of the deviation value, as well as the quantitative distribution of deviation values ​​in each interval. These deviation data reflect the degree of discreteness of the access characteristics of different data blocks, and provide an important reference for subsequent weighted corrections. By calculating the deviation value, the system can identify data blocks with abnormal access characteristics. The read-write ratio of these data blocks is greatly different from the overall average level, and special processing is required in subsequent corrections.

[0037] Step 234: Perform weighted correction on the arithmetic mean based on each deviation value, and determine the corrected arithmetic mean as the concentrated characteristic value.

[0038] Specifically, the system performs weighted correction on the arithmetic mean based on the deviation value obtained in the above steps. First, the system sets a baseline deviation range. When the deviation value of a data block exceeds the range, it is judged as an abnormal value. These abnormal values ​​will be given a smaller weight in weighted calculation. For deviation values ​​within the normal range, the system adopts a decreasing weighting method, that is, the data block with a smaller deviation value obtains a larger weight. For example, the deviation value can be divided into multiple intervals according to the size. The weight of the data block with a deviation value in the smallest interval is one. As the deviation value increases, the weight decreases to 0.8, 0.6, etc. The system uses these weight values ​​to multiply the read-write ratio of the corresponding data block, sums all the weighted read-write ratios, and then divides it by the sum of the weights to obtain the corrected arithmetic mean, and determines it as the final concentrated feature value. This weighted correction mechanism can reduce the impact of abnormal data, so that the concentrated feature value more accurately reflects the main access characteristics of the hard disk area, and provides a more reliable basis for the subsequent determination of the dynamic classification threshold. At the same time, due to the use of a deviation-based dynamic weight allocation method, this correction method can adapt to data access patterns in different application scenarios and improve the accuracy and adaptability of eigenvalue calculation.

[0039] Step 205: When the read-write ratio is greater than or equal to the dynamic classification threshold, the corresponding data block is used as a read priority block; when the read-write ratio is less than the dynamic classification threshold, the corresponding data block is used as a write priority block.

[0040] Specifically, the system uses a dynamic classification threshold to classify data blocks in the hard disk area. The read-write ratio of each data block is read in turn and compared with the dynamic classification threshold. When the read-write ratio of a data block is greater than or equal to the dynamic classification threshold, it means that the read operation of the data block is significantly more than the write operation. The system marks it as a read priority block and updates the attribute identifier of the data block in the management table of the solid-state hard disk. When the read-write ratio of a data block is less than the dynamic classification threshold, it means that the write operation of the data block is relatively frequent. The system marks it as a write priority block and also updates the attribute identifier in the management table. Through this dynamic classification method, the system can classify data blocks into two categories: read priority blocks and write priority blocks according to the actual data access mode. This classification result can accurately reflect the usage characteristics of the data blocks and provide a reliable decision-making basis for subsequent wear leveling operations. For example, when data migration is required, the system will give priority to write priority blocks as source data blocks and read priority blocks as target data blocks, thereby achieving more targeted wear leveling control. At the same time, since the classification threshold is dynamically calculated based on the overall characteristics of the hard disk area, this classification method can adapt to data access patterns in different application scenarios, improving the accuracy and efficiency of wear leveling.

[0041] Step 103: Obtain the ratio of the number of read priority blocks to the number of write priority blocks in each hard disk area. When the ratio of any hard disk area exceeds a preset ratio range, the corresponding hard disk area is determined as an area to be balanced.

[0042] Among them, the preset ratio range in this embodiment refers to the number ratio interval used to determine whether the hard disk area needs to be wear-leveled. This range is determined based on the statistical distribution characteristics of read and write operations of the solid-state hard disk under normal use. When the number ratio in the hard disk area is within this range, it indicates that the data block distribution in the area is relatively balanced and does not need to be worn out immediately; when the ratio exceeds this range, it indicates that the data block distribution in the area is obviously unbalanced and needs to be adjusted through data migration.

[0043] In this embodiment, the area to be balanced refers to the hard disk area whose quantity ratio exceeds the preset ratio range.

[0044] Specifically, the system analyzes and evaluates the data block distribution status of each hard disk area in the solid state drive. First, the system reads the number information of read priority blocks and write priority blocks in each hard disk area from the management table of the solid state drive. Based on this number information, the system calculates the number ratio of each hard disk area by dividing the number of read priority blocks by the number of write priority blocks. For example, if there are 800 read priority blocks and 200 write priority blocks in a hard disk area, its number ratio is 4. The system pre-sets a reasonable ratio range, such as [1.5, 6], which is determined based on the distribution characteristics of read and write operations when the solid state drive is in normal use. When the number ratio of a hard disk area is less than 1.5 or greater than 6, it indicates that the data block distribution in the area has significantly deviated. If the ratio is too low, it means that there are too many write priority blocks in the area, which may cause the storage unit in the area to bear greater write pressure; if the ratio is too high, it means that the read priority blocks are too concentrated, which is not conducive to the load balancing of subsequent write operations. Therefore, the system marks the hard disk areas whose number ratios exceed the preset range as areas to be balanced, and gives priority to these areas in the subsequent wear leveling process. This evaluation method based on quantity ratio can timely identify hard disk areas with uneven data block distribution, adjust the distribution of read-write priority blocks through targeted data migration, ensure that the degree of wear of storage units in various areas of the solid-state drive is consistent, and thus extend the service life of the solid-state drive. At the same time, because the preset ratio range is used as the judgment standard, this evaluation method has strong adaptability and can effectively identify hard disk areas that need wear leveling in different application scenarios.

[0045] Step 104: Select the write priority block with the largest number of erase / write times from the area to be balanced as the first target block, and select the read priority block with the smallest number of erase / write times from the remaining hard disk area as the second target block.

[0046] The first target block in this embodiment refers to a write priority block with the largest number of erase times selected from the area to be balanced, and is used as a source data block for data migration.

[0047] In this embodiment, the second target block refers to a read priority block with the least number of erase and write times selected from the non-to-be-balanced area (ie, the remaining hard disk area) as a target data block for data migration.

[0048] Specifically, the system first accesses the wear status table of the solid-state hard disk, which records the number of erasures of each data block. For the identified area to be balanced, the system traverses all the write priority blocks therein, compares their number of erasures, and finds the write priority block with the most erasures as the first target block. The write priority block with the most erasures is selected because the storage unit where the data block is located is under the greatest write pressure, has the highest degree of wear, and is most in need of data migration. Next, the system traverses other hard disk areas except the area to be balanced, finds the data block with the least number of erasures from the read priority blocks in these areas, and uses it as the second target block. The read priority block with the least number of erasures is selected because the storage unit where the data block is located has a low degree of wear and has sufficient erasure margin to receive the data in the first target block. For example, if the number of erasures of the first target block is 1000, and the number of erasures of the second target block is only 100, then by migrating data from the first target block to the second target block, the frequency of use of the high-wear storage unit can be significantly reduced. This selection strategy based on the number of erase and write cycles can balance the wear status of each storage unit to the greatest extent. By migrating frequently written data to storage units with lower wear levels, it achieves more precise and efficient wear leveling control, effectively extending the service life of the solid-state drive.

[0049] Step 105: Migrate the data in the first target block to the second target block.

[0050] Specifically, first, the system reads the data of the first target block into the cache for temporary storage, and records the metadata information of the data block, including the logical address mapping relationship of the data and the data block attributes. Then, the system checks the status of the second target block to ensure that it is in a writable state and has sufficient storage space. If there is already data in the second target block, the system will transfer the data to other appropriate data blocks. Then, the system writes the data in the cache to the second target block, and updates the corresponding mapping table to remap the logical address originally pointing to the first target block to the physical address of the second target block. After completing the data migration, the system marks the first target block as invalid and waits for subsequent garbage collection operations. This data migration operation can realize the dynamic transfer of write loads, and transfer frequently written data from storage units with severe wear to storage units with less wear. In this way, the system realizes the dynamic balance of the wear degree of storage units, effectively extending the service life of the solid-state hard disk. At the same time, since the cache is used as a transit in the data migration process and the logical address mapping relationship of the data is maintained, the transparency of the data migration operation to the upper-layer application is ensured, and the normal read and write operations will not be affected.

[0051] Based on the above embodiment, as an optional embodiment, in step 105: migrating the data in the first target block to the second target block, this step may also include the following steps: Step 301: Obtain the amount of data to be migrated of a first target block and the available storage capacity of a second target block; when the amount of data to be migrated is less than or equal to the available storage capacity, write the data in the first target block into the second target block.

[0052] Specifically, the system first needs to confirm the feasibility of the data migration operation. The system reads the data size information of the first target block, obtains the total amount of data to be migrated, and checks the storage status of the second target block to calculate its currently available storage space. By comparing these two values, the system can determine whether the second target block can completely accommodate all the data in the first target block. When the amount of data to be migrated is less than or equal to the available storage capacity, it indicates that the second target block has sufficient space, and the system directly performs the data write operation. Specifically, the system reads the data in the first target block into the cache and then writes it to the second target block. This direct data migration method can ensure the integrity of the data and reduce the management overhead caused by distributed data storage.

[0053] Step 302: When the data volume is greater than the available storage capacity, at least one read priority block with the largest available storage capacity is selected from the remaining hard disk area as a spare target block.

[0054] Specifically, when the system finds that the amount of data in the first target block exceeds the available capacity of the second target block, it needs to find additional storage space to accommodate the remaining data. The system will scan other hard disk areas except the area to be balanced, count the available storage capacity of all read priority blocks, and sort them according to capacity size. Then select the read priority block with the largest available capacity as the backup target block. If the capacity of a single read priority block is still insufficient, you may need to select multiple read priority blocks. Selecting the read priority block with the largest available capacity can reduce the degree of data dispersion and facilitate subsequent data management and access. In addition, since read priority blocks are selected, these data blocks were originally used mainly for read operations and have a lower number of erase and write times, which are suitable for receiving data from high wear areas.

[0055] Step 303: write data exceeding the available storage capacity of the second target block into the spare target block; and update the address mapping relationship between the first target block, the second target block and the spare target block.

[0056] Specifically, the system performs a segmented data migration operation. First, the system calculates the amount of data that the second target block can accommodate, and writes this part of the data into the second target block; then the remaining data is written into the previously selected spare target block. After completing the data writing, the system needs to update the address mapping table to map the logical address originally pointing to the first target block to the corresponding physical addresses of the second target block and the spare target block respectively. This segmented migration strategy can achieve complete data migration even when the capacity of the second target block is insufficient, ensuring the effective execution of the wear leveling operation. By updating the address mapping relationship, the system ensures that the upper-level application can correctly access the migrated data while maintaining the logical continuity of the data. This data migration scheme based on multiple target blocks enhances the flexibility and reliability of the system when handling large-capacity data migration, and effectively supports the wear leveling management of solid-state drives.

[0057] Based on the above embodiment, as an optional embodiment, in step 303: updating the address mapping relationship between the first target block and the second target block and the spare target block, this step may also include the following steps: Step 313: Obtain an original logical address corresponding to the first target block; and delete the mapping relationship between the original logical address and the physical addresses of the first target block and the spare target block in the address mapping table.

[0058] Specifically, the system needs to update the address mapping relationship of the solid-state drive. First, the system searches the address mapping table for the original logical address information currently corresponding to the first target block. The original logical address is the address used by the upper-level application to access data, and there is a one-to-one mapping relationship with the physical address of the first target block. Since the data will be migrated to a new physical location, the system needs to clear these outdated mapping relationships from the address mapping table. The specific operation is that the system locates all mapping items related to the original logical address in the address mapping table, including mapping relationships pointing to the first target block and the spare target blocks that may have been used before, and then marks these mapping items as invalid or directly deletes them. The purpose of this is to prepare for the subsequent establishment of a new mapping relationship, avoid address mapping conflicts, and ensure the accuracy of data access.

[0059] Step 323: According to the write data in the second target block and the spare target block, the original logical address is mapped to the physical address corresponding to the second target block and the spare target block respectively.

[0060] Specifically, the system establishes a new address mapping relationship according to the actual situation of data migration. The system first confirms the data range actually written in the second target block and the spare target block. This range information can help the system accurately divide the mapping interval of the logical address. For the data part written to the second target block, the system maps the corresponding original logical address segment to the physical address of the second target block; for the data part written to the spare target block, the system maps the corresponding original logical address segment to the physical address of the spare target block. For example, if the original data block size is 8KB, of which 5KB is written to the second target block and 3KB is written to the spare target block, then the system will map the first 5KB of the original logical address to the physical address of the second target block, and the last 3KB to the physical address of the spare target block. This mapping method based on the actual data distribution ensures that the upper-level application can accurately access the migrated data while maintaining the continuity of the data at the logical level. Through this precise address mapping update, the system realizes the transparency of the data migration process to the upper-level application, ensuring the correctness and efficiency of data access.

[0061] Based on the above embodiment, as an optional embodiment, in step 323: according to the write data in the second target block and the spare target block, the original logical address is mapped to the physical address corresponding to the second target block and the spare target block respectively. This step may also include the following steps: Step 401: Calculate a first relative offset of data written in a second target block and a second relative offset of data written in a spare target block.

[0062] Specifically, the system needs to accurately calculate the distribution of data in the new storage location. First, the system obtains the starting position and the ending position of the data actually written in the second target block, and obtains the first relative offset by calculating the difference between these two positions and the starting address of the second target block. Similarly, the system also calculates the starting position and the ending position of the data written in the spare target block to obtain the second relative offset. For example, if data is written starting from the 1024th byte position in the second target block, the first relative offset is 1024; if data is written starting from the 512th byte position in the spare target block, the second relative offset is 512. These offset information are crucial for the subsequent establishment of an accurate address mapping relationship because they reflect the actual distribution position of the data in the physical storage space.

[0063] Step 402: In the original logical address, determine a first address segment corresponding to the first relative offset and a second address segment corresponding to the second relative offset.

[0064] Specifically, the system divides the original logical address space according to the calculated relative offset. The system first obtains the starting position of the original logical address, and then determines the range of the first address segment according to the first relative offset, and this part of the address corresponds to the data written to the second target block; then determines the range of the second address segment according to the second relative offset, and this part of the address corresponds to the data written to the spare target block. For example, assuming that the original logical address is 0x1000-0x3000, where the data of 0x1000-0x2000 is written to the second target block, and the data of 0x2000-0x3000 is written to the spare target block, then the first address segment is 0x1000-0x2000, and the second address segment is 0x2000-0x3000. This offset-based address segment division ensures that the corresponding relationship between the data in the logical space and the physical space remains consistent.

[0065] Step 403: Map the first address segment to the physical address of the second target block, and map the second address segment to the physical address of the spare target block.

[0066] Specifically, the system performs an actual address mapping update operation. The system first establishes a mapping relationship between the first address segment and the physical address of the second target block, and writes this mapping information into the address mapping table. Similarly, the system establishes a mapping relationship between the second address segment and the physical address of the spare target block, and also writes this mapping information into the address mapping table. For example, if the data of the first address segment 0x1000-0x2000 is stored in the physical address 0xA000-0xB000 of the second target block, a mapping of the physical address 0x1000-0x2000 to 0xA000-0xB000 is established in the address mapping table; if the data of the second address segment 0x2000-0x3000 is stored in the physical address 0xC000-0xD000 of the spare target block, a mapping of 0x2000-0x3000 to 0xC000-0xD000 is established. This precise address mapping mechanism ensures that the system can correctly locate and access dispersed stored data after data migration, while maintaining the continuity of data at the logical level and improving the efficiency of data access.

[0067] Reference Figure 2 , a wear leveling system for a solid state drive provided in an embodiment of the present application, the system comprises: a data acquisition module, a priority block determination module, a region determination module, and a data migration module, wherein: A data acquisition module, used to acquire access characteristic data of each data block in multiple hard disk areas; A priority block determination module is used to determine the read-write ratio of the corresponding data block within a preset time window in each hard disk area based on the access characteristic data of each data block, and determine the corresponding data block as a read priority block or a write priority block according to each read-write ratio; A region determination module, used to obtain the ratio of the number of read priority blocks to the number of write priority blocks in each hard disk region, and when the ratio of the number of any hard disk region exceeds a preset ratio range, the corresponding hard disk region is determined as a region to be balanced; The data migration module is used to select the write priority block with the most erase and write times from the area to be balanced as the first target block, and select the read priority block with the least erase and write times from the remaining hard disk area as the second target block; and migrate the data in the first target block to the second target block.

[0068] On the basis of the above embodiment, the priority block determination module is also used to extract the number of reads and writes of the corresponding data block within the preset time window from each access feature data; based on the duration corresponding to each read number and the preset time window, the read frequency of the corresponding data block is calculated, and based on the duration corresponding to each write number and the preset time window, the write frequency of the corresponding data block is calculated; and the ratio between the read frequency and the write frequency of each data block is used as the read-write ratio of the corresponding data block.

[0069] On the basis of the above-mentioned embodiment, the priority block determination module is also used to calculate the concentrated characteristic value of the read-write ratio based on the read-write ratio of each data block in the hard disk area, and determine the dynamic classification threshold according to the concentrated characteristic value; when the read-write ratio is greater than or equal to the dynamic classification threshold, the corresponding data block is used as a read priority block, and when the read-write ratio is less than the dynamic classification threshold, the corresponding data block is used as a write priority block.

[0070] Based on the above embodiment, the priority block determination module is also used to calculate the arithmetic mean of the read-write ratio of each data block in the hard disk area; determine the deviation value between each read-write ratio and the arithmetic mean; perform weighted correction on the arithmetic mean based on each deviation value, and determine the corrected arithmetic mean as the concentrated characteristic value.

[0071] On the basis of the above embodiment, the data migration module is also used to obtain the amount of data to be migrated of the first target block and the available storage capacity of the second target block; when the amount of data to be migrated is less than or equal to the available storage capacity, the data in the first target block is written into the second target block; when the amount of data is greater than the available storage capacity, at least one read priority block with the largest available storage capacity is selected from the remaining hard disk area as a spare target block; data exceeding the available storage capacity of the second target block is written into the spare target block; and the address mapping relationship between the first target block and the second target block and the spare target block is updated.

[0072] Based on the above embodiment, the data migration module is also used to obtain the original logical address corresponding to the first target block; delete the mapping relationship between the original logical address and the physical addresses of the first target block and the spare target block in the address mapping table; and map the original logical address to the physical addresses corresponding to the second target block and the spare target block respectively according to the write data in the second target block and the spare target block.

[0073] Based on the above embodiment, the data migration module is also used to calculate the first relative offset of the data written in the second target block and the second relative offset of the data written in the spare target block; in the original logical address, determine the first address segment corresponding to the first relative offset and the second address segment corresponding to the second relative offset; map the first address segment to the physical address of the second target block, and map the second address segment to the physical address of the spare target block.

[0074] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0075] This application also discloses an electronic device. Refer to Figure 3 , Figure 3 which is a schematic structural diagram of an electronic device disclosed in an embodiment of this application. The electronic device 300 may include: at least one processor 301, at least one network interface 304, a user interface 303, a memory 305, and at least one communication bus 302.

[0076] Among them, the communication bus 302 is used to implement connection communication between these components.

[0077] Among them, the user interface 303 may include a display interface and a camera interface. Optionally, the user interface 303 may further include a standard wired interface and a wireless interface.

[0078] Among them, the network interface 304 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).

[0079] Among them, the processor 301 may include one or more processing cores. The processor 301 connects various parts within the entire server using various interfaces and lines, and by running or executing instructions, programs, code sets, or instruction sets stored in the memory 305, as well as calling data stored in the memory 305, it executes various functions of the server and processes data. Optionally, the processor 301 may be implemented in at least one of the following hardware forms: Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 301 may integrate one or a combination of several of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface graphics, and application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 301 and may be implemented separately by a single chip.

[0080] Among them, the memory 305 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 305 may optionally also be at least one storage device located away from the aforementioned processor 301. Refer to Figure 3 , the memory 305 as a computer storage medium may include an operating system, a network communication module, a user interface module and an application program of a wear leveling method for a solid state hard disk.

[0081] exist Figure 3 In the electronic device 300 shown, the user interface 303 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 301 can be used to call the application program of a wear leveling method for a solid state hard disk stored in the memory 305. When executed by one or more processors 301, the electronic device 300 executes one or more methods in the above-mentioned embodiments. It should be noted that for the aforementioned method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.

[0082] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0083] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

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

[0085] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0086] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, 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, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: various media that can store program codes, such as USB flash drives, mobile hard drives, magnetic disks or optical disks.

[0087] The above are only exemplary embodiments of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and practice, those skilled in the art will easily think of other embodiments of the present disclosure.

[0088] This application is intended to cover any variation, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the art not recorded in the present disclosure. The description and examples are to be regarded as exemplary only.

Claims

1. A wear leveling method for a solid state drive, characterized in that: include: Obtain access characteristic data of each data block in multiple hard disk areas; In each of the hard disk areas, based on the access characteristic data of each of the data blocks, determining the read-write ratio of the corresponding data block within a preset time window, and determining the corresponding data block as a read priority block or a write priority block according to each of the read-write ratios; Obtaining a ratio of the number of read priority blocks to the number of write priority blocks in each of the hard disk areas, and when the ratio of the number of any hard disk area exceeds a preset ratio range, determining the corresponding hard disk area as an area to be balanced; Selecting a write priority block with the most erase / write times from the area to be balanced as a first target block, and selecting a read priority block with the least erase / write times from the remaining hard disk area as a second target block; The data in the first target block is migrated to the second target block.

2. The wear leveling method for a solid state drive according to claim 1, characterized in that: The determining, based on the access characteristic data of each data block, a read-write ratio of a corresponding data block within a preset time window includes: Extracting the number of reads and writes of the corresponding data block within a preset time window from each of the access characteristic data; Based on each of the read times and the duration corresponding to the preset time window, calculate the read frequency of the corresponding data block, and based on each of the write times and the duration corresponding to the preset time window, calculate the write frequency of the corresponding data block; The ratio between the reading frequency and the writing frequency of each data block is used as the reading and writing ratio of the corresponding data block.

3. The wear leveling method for a solid state drive according to claim 1, wherein: The step of determining the corresponding data block as a read priority block or a write priority block according to each of the read-write ratios includes: Based on the read-write ratio of each data block in the hard disk area, calculating a concentrated feature value of the read-write ratio, and determining a dynamic classification threshold according to the concentrated feature value; When the read-write ratio is greater than or equal to the dynamic classification threshold, the corresponding data block is used as a read priority block; when the read-write ratio is less than the dynamic classification threshold, the corresponding data block is used as a write priority block.

4. The wear leveling method for a solid state drive according to claim 3, characterized in that: The calculating of the concentrated characteristic value of the read-write ratio based on the read-write ratio of each data block in the hard disk area includes: Calculating the arithmetic mean of the read-write ratio of each data block in the hard disk area; Determine the deviation value between each of the read-write ratios and the arithmetic mean; The arithmetic mean is weightedly corrected based on each of the deviation values, and the corrected arithmetic mean is determined as the concentrated characteristic value.

5. The wear leveling method for a solid state drive according to claim 1, characterized in that: The step of migrating the data in the first target block to the second target block includes: Acquire the amount of data to be migrated of the first target block and the available storage capacity of the second target block; When the amount of data to be migrated is less than or equal to the available storage capacity, writing the data in the first target block into the second target block; When the data volume is greater than the available storage capacity, selecting at least one read priority block with the largest available storage capacity from the remaining hard disk area as a spare target block; Writing data exceeding the available storage capacity of the second target block into the spare target block; Update the address mapping relationship between the first target block, the second target block and the spare target block.

6. The wear leveling method for a solid state drive according to claim 5, characterized in that: The updating of the address mapping relationship between the first target block, the second target block, and the spare target block includes: Obtaining an original logical address corresponding to the first target block; Deleting the mapping relationship between the original logical address and the physical addresses of the first target block and the spare target block in the address mapping table; According to the written data in the second target block and the spare target block, the original logical address is mapped to the physical addresses corresponding to the second target block and the spare target block respectively.

7. The wear leveling method for a solid state drive according to claim 6, wherein: The mapping of the original logical address to the physical addresses corresponding to the second target block and the spare target block respectively according to the written data in the second target block and the spare target block comprises: Calculating a first relative offset of data written in the second target block and a second relative offset of data written in the standby target block; In the original logical address, determining a first address segment corresponding to the first relative offset and a second address segment corresponding to the second relative offset; The first address segment is mapped to a physical address of the second target block, and the second address segment is mapped to a physical address of the spare target block.

8. A wear leveling system for a solid state drive, characterized in that: The system comprises: A data acquisition module, used to acquire access characteristic data of each data block in multiple hard disk areas; A priority block determination module is used to determine, in each of the hard disk areas, a read-write ratio of a corresponding data block within a preset time window based on access characteristic data of each of the data blocks, and determine the corresponding data block as a read priority block or a write priority block according to each of the read-write ratios; A region determination module, used for obtaining the ratio of the number of read priority blocks to the number of write priority blocks in each hard disk region, and when the ratio of the number of any hard disk region exceeds a preset ratio range, determining the corresponding hard disk region as a region to be balanced; A data migration module is used to select the write priority block with the most erase and write times from the area to be balanced as the first target block, and select the read priority block with the least erase and write times from the remaining hard disk area as the second target block; and migrate the data in the first target block to the second target block.

9. An electronic device, characterized in that: It includes a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes the wear leveling method for a solid state hard disk as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed, the wear leveling method for a solid state drive as described in any one of claims 1 to 7 is executed.

Citation Information

Patent Citations

  • Medium access management method of solid state disk and solid state disk

    CN113778821A

  • Systems and methods for storage recovery

    US20160188219A1

  • Storage system and operating method thereof

    US20250077104A1