A wear leveling processing method of a storage device, a storage device, and a storage medium

CN122173412APending Publication Date: 2026-06-09合肥康芯威存储技术有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
合肥康芯威存储技术有限公司
Filing Date
2026-05-11
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

In existing technologies for flash memory storage devices, the existing technology cannot perform differentiated lifespan management based on the actual degradation degree of different physical blocks. This results in some physical blocks having wasted lifespan due to conservative static thresholds, and passive error correction methods pose a risk of data loss.

Method used

By periodically inspecting the storage device during idle periods to obtain the health parameters of each storage page within a physical block, performing extreme value removal, and then dynamically adjusting the allowable erase/write count threshold of the physical block based on differential weighted statistics of quantile distribution, fine-grained lifetime management is achieved.

Benefits of technology

By effectively utilizing high-quality physical blocks, the risk of data loss can be reduced, and the overall durability and data security of storage devices can be improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122173412A_ABST
    Figure CN122173412A_ABST
Patent Text Reader

Abstract

This application provides a wear leveling method, storage device, and storage medium for a storage device. The method includes periodically inspecting and acquiring health parameters of each storage page within a physical block during the storage device's idle state. After removing extreme values ​​from the health parameters, a differentiated weighted statistical analysis based on quantile distribution is performed to proactively assess the health level reflecting the true degradation state of the physical block. Based on this health level, the allowable write / erase count threshold for the physical block is dynamically adjusted. Compared to existing wear leveling methods that use fixed thresholds or only count write cycles, this application performs differentiated lifetime management based on the actual health state of different physical blocks, allowing high-quality physical blocks to fully utilize their remaining value and avoiding wasted lifetime due to conservative static thresholds.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of storage device technology, specifically to a wear leveling method for a storage device, a storage device, and a storage medium. Background Technology

[0002] Storage devices typically contain non-volatile storage media such as flash memory. Control chips manage each physical block, and wear leveling is one of the key technologies for extending device lifespan. After multiple programming and erasing operations, the oxide layer of the flash memory chip gradually degrades, leading to bit errors during data reading, affecting data reliability and the lifespan of the storage device. Therefore, properly managing the lifespan of each physical block in a flash memory storage device is a crucial technology for ensuring data security and improving device durability.

[0003] Currently, flash memory physical block lifetime management typically employs a fixed maximum write / erase cycle threshold for each physical block. When a physical block reaches this threshold, it is marked as a bad block and decommissioned. While this static threshold method is simple to implement, it fails to adequately consider the differences in actual degradation rates among different physical blocks due to factors such as process variations and operating temperature, resulting in wasted remaining lifetime of some high-quality physical blocks. Furthermore, existing technologies also include reactive, post-hoc management methods based on error correction code failures, only addressing uncorrectable errors during data reading, which carries the risk of data loss. Other solutions achieve wear leveling by statistically analyzing the write cycles of each physical block, making the write cycles roughly equal. However, these methods only focus on the even distribution of write cycles and fail to reflect the true physical degradation state of each physical block, thus still struggling to achieve refined lifetime management. Summary of the Invention

[0004] This application provides a wear leveling method for storage devices, a storage device, and a storage medium, aiming to solve the technical problem that the prior art lacks the ability to actively assess the true health status of physical blocks and cannot adjust the lifetime threshold differently according to the actual degradation degree of different physical blocks, thus limiting the improvement of the overall durability and data security of storage devices.

[0005] In a first aspect, embodiments of this application provide a wear leveling method for a storage device, comprising:

[0006] When the storage device is idle, periodic inspections are performed to obtain the health parameters of each storage page in the target physical block of the storage device, thereby obtaining the storage page health parameter set of the target physical block;

[0007] The storage page health parameter set is subjected to extreme value removal processing to obtain the effective health parameter set of the storage page;

[0008] The health of the target physical block is determined by performing differential weighted statistics based on quantile distribution on the set of effective health parameters.

[0009] Based on the pre-defined mapping relationship between health status and maximum number of erase / write cycles, the threshold for the number of erase / write cycles allowed in the current state of the target physical block is dynamically adjusted.

[0010] In some embodiments, the health parameters include at least one of bit error rate, number of error correction failures, number of rereads, read latency, write latency, and erase latency.

[0011] In some embodiments, the process of removing extreme values ​​from the storage page health parameter set includes:

[0012] Sort the health parameter values ​​in the storage page health parameter set by size;

[0013] Based on a preset first ratio and a second ratio, the header data of the first ratio and the tail data of the second ratio in the storage page health parameter set are removed to obtain the effective health parameter set of the storage page.

[0014] In some embodiments, determining the health of the target physical block by performing differential weighted statistics based on quantile distribution on the effective health parameter set includes:

[0015] Determine at least one quantile value for the weight interval used to divide the effective set of health parameters;

[0016] Assign corresponding weights to the divided weight intervals, where the weight interval with the larger health parameter value has a larger corresponding weight;

[0017] The health of the target physical block is calculated based on the health parameters and their respective weight ranges.

[0018] In some embodiments, when the health parameters include multiple parameters, the step of calculating a weighted statistical value as the health of the target physical block based on the health parameters and the weight values ​​of their respective weight intervals includes:

[0019] Calculate the weighted average value corresponding to each health parameter based on the weight value of each weight interval to which it belongs;

[0020] Based on the normalized reference base value corresponding to each of the health parameters, the weighted average value corresponding to each of the health parameters is normalized to obtain the normalized feature value corresponding to each of the health parameters.

[0021] Based on the normalized feature value corresponding to each health parameter and its fusion weight to the health of the target physical block, a weighted statistical value is calculated as the health of the target physical block.

[0022] In some embodiments, the health status is inversely correlated with the maximum number of erasable and rewritable cycles, and the mapping relationship is pre-stored in the controller of the storage device through a lookup table or piecewise function.

[0023] In some embodiments, the wear leveling method for the storage device further includes:

[0024] Record the historical trend of the health status of the target physical block;

[0025] Based on the historical trend, update the mapping relationship between the pre-calibrated health status and the maximum number of erasable and rewritable cycles.

[0026] In some embodiments, the wear leveling method for the storage device further includes:

[0027] Based on the health status of each physical block, the health levels of multiple physical blocks in the storage device are classified.

[0028] Adjust the data allocation strategy for each physical block according to the health level;

[0029] And / or, obtain the current number of erase / write operations on the target physical block;

[0030] When the current number of erase / write operations reaches or exceeds the adjusted allowed number of erase / write operations threshold, the target physical block is marked as an unusable block.

[0031] Secondly, embodiments of this application provide a storage device, including:

[0032] A storage unit includes multiple physical blocks, and each physical block includes multiple storage pages;

[0033] The control unit includes an acquisition module, a processing module, and an adjustment module;

[0034] The acquisition module is configured to periodically inspect and acquire the health parameters of each storage page in the target physical block of the storage unit when the storage device is idle, so as to obtain the storage page health parameter set of the target physical block;

[0035] The processing module is configured to perform extremum removal processing on the storage page health parameter set, and perform differential weighted statistics based on quantile distribution on the processed effective health parameter set to determine the health of the target physical block;

[0036] The adjustment module is configured to dynamically adjust the threshold of the number of erase / write cycles allowed for the target physical block in the storage unit under the current state, based on a pre-defined mapping relationship between health and maximum number of erase / write cycles.

[0037] Thirdly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the wear leveling processing method for a storage device as described in any embodiment of the first aspect.

[0038] The storage device and its wear leveling method provided in this application periodically inspect the health parameters of each storage page within a physical block during the storage device's idle state. After removing extreme values ​​from the health parameters, a differentiated weighted statistical analysis based on quantile distribution is performed to proactively assess the health level reflecting the true degradation state of the physical block. Based on this health level, the allowable write / erase count threshold of the physical block is dynamically adjusted. Compared to existing wear leveling methods that use fixed thresholds or only count write counts, this application performs differentiated lifetime management based on the actual health state of different physical blocks, allowing high-quality physical blocks to fully utilize their remaining value and avoiding lifetime waste caused by conservative static thresholds. Simultaneously, proactively inspecting and assessing the health state of physical blocks and adjusting their available write / erase count thresholds in advance, compared to passively waiting for error correction failures, can identify physical blocks at risk of degradation earlier and restrict their continued use, effectively reducing the risk of data loss and significantly improving the overall durability and data security of the storage device.

[0039] In addition, this application also provides a computer-readable storage medium that has the same beneficial effects as the storage resource reorganization method of the flash memory device described above. Attached Figure Description

[0040] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0041] Figure 1 This is a schematic diagram of the structure of a storage device provided in one embodiment of this application.

[0042] Figure 2 This is a flowchart of a wear leveling method for a storage device provided in one embodiment of this application.

[0043] Figure 3 A flowchart of a wear leveling method for a storage device provided in another embodiment of this application.

[0044] Figure 4A flowchart of a wear leveling method for a storage device provided in another embodiment of this application.

[0045] Figure 5 A flowchart of a wear leveling method for a storage device provided in another embodiment of this application.

[0046] Figure 6 A flowchart of a wear leveling method for a storage device provided in another embodiment of this application.

[0047] Figure 7 A flowchart of a wear leveling method for a storage device provided in another embodiment of this application.

[0048] Figure 8 A flowchart of a wear leveling method for a storage device provided in another embodiment of this application.

[0049] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0050] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings. Similar elements in different embodiments are referred to by associated similar element reference numerals. In the following embodiments, many details are described to facilitate a better understanding of the invention. However, those skilled in the art will readily recognize that some features may be omitted in different situations, or may be replaced by other elements, materials, or methods. In some cases, certain operations related to the present invention are not shown or described in the specification. This is to avoid obscuring the core parts of the invention with excessive description. For those skilled in the art, detailed description of these related operations is not necessary; they can fully understand the related operations based on the description in the specification and general technical knowledge in the art.

[0051] Furthermore, the features, operations, or characteristics described in the specification can be combined in any suitable manner to form various embodiments. At the same time, the steps or actions in the method description can be rearranged or adjusted in a manner obvious to those skilled in the art. Therefore, the various orders in the specification and drawings are only for the clear description of a particular embodiment and do not imply a necessary order, unless otherwise stated that a particular order must be followed.

[0052] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship. Unless otherwise specified, the terms "connection" and "linkage" used in this application include both direct and indirect connections (linkages).

[0053] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0054] Figure 1 This is a schematic diagram of the structure of a storage device provided in one embodiment of this application. Figure 1 As shown, the storage device provided in this embodiment includes a storage unit 10 and a control unit 20.

[0055] In this embodiment, the storage unit 10 includes multiple physical blocks, and each physical block includes multiple storage pages. The storage unit 10 uses non-volatile flash memory media, such as NAND Flash, as the storage medium. A physical block is the smallest unit for performing an erase operation, typically containing tens to hundreds of storage pages; a storage page is the basic unit for performing read and write operations, and each storage page contains a data area and a redundancy area, where the redundancy area is used to store error correction coding verification information and manage metadata. In the storage unit 10, programming and reading operations are performed on a per-page basis, while erase operations must be performed on a per-block basis. This asymmetric operation characteristic makes the physical block a key object for lifetime management. Due to the physical characteristics of NAND flash memory, before writing data to a page, an erase operation must first be performed on the entire physical block containing that page. Each physical block has a preset maximum nominal number of erase cycles, which is determined by the flash memory manufacturing process and is typically between several thousand and tens of thousands of cycles. As physical blocks undergo an increasing number of program / erase cycles, the tunneling oxide layer of the floating-gate transistors that make up the memory pages gradually degrades, reducing electron retention capacity. This leads to a gradual increase in bit errors during data reading, which can eventually exceed the correction capabilities of error correction codes, resulting in data loss and affecting data storage reliability. Therefore, in traditional flash memory management strategies, physical blocks that have reached their lifetime limit are marked as bad blocks and removed from the available resource pool.

[0056] The control unit 20, as the core control component of the storage device, is configured to perform basic storage management functions of the flash memory device, including but not limited to: address mapping, garbage collection, wear leveling, bad block management, and other conventional flash memory management functions. Specifically, the address mapping function converts logical address requests issued by the host into physical addresses of flash memory physical blocks in real time and maintains a mapping table between logical addresses and physical addresses. When data is updated or migrated, the mapping relationship is updated synchronously. This mechanism is introduced because flash memory does not support in-situ updates; after data is written to a new location, the original location needs to be marked as invalid. The garbage collection function is triggered when the available space of the storage device is lower than a preset threshold. It is responsible for moving the still valid storage page data in the target physical block to other physical blocks, and then performing an erase operation on the entire target physical block, reclaiming it into a free state for subsequent writing. This function is a necessary requirement determined by the physical characteristic of flash memory that it must perform an erase operation before it can be rewritten. Wear leveling, by statistically recording the cumulative number of erases and writes to each physical block since its inception, prioritizes idle physical blocks with fewer erase and write cycles when writing data to allocated physical blocks. This maintains a relatively balanced level of erase and write cycles across all physical blocks, preventing premature bad blocks caused by concentrated and frequent erases in certain areas, which would reduce the overall usable capacity and lifespan of the storage device. Bad block management identifies and marks initial bad blocks caused by manufacturing defects during the storage device's factory testing phase. During use, it monitors and marks growing bad blocks caused by excessive wear, permanently removing them from the usable physical block pool and replacing them with reserved spare physical blocks. This ensures that the storage device can maintain its nominal storage capacity and normal read / write functionality even after some physical blocks fail.

[0057] The above-mentioned conventional flash memory management functions provide a basic guarantee for the stable operation of storage devices. However, when implementing physical block lifetime management, the wear leveling function uses the number of erase / write cycles as the sole metric, without considering the differences in the actual physical degradation rate of different physical blocks due to factors such as process variations and operating temperature gradients. Under the same number of erase / write cycles, the degree of oxide layer degradation and bit error rate of different physical blocks may vary significantly, and the actual remaining lifetime of each physical block cannot be accurately determined based solely on the number of erase / write cycles.

[0058] Based on this, the control unit 20 in this embodiment is configured to execute an improved wear leveling method. This method, which focuses only on the balance of physical block write counts in traditional wear leveling, further introduces an active assessment mechanism for the actual health status of physical blocks. That is, it performs differentiated lifetime management based on the actual health status of different physical blocks. During the idle state of the storage device, it periodically inspects and obtains the health parameters of each storage page in the physical block. After removing extreme values ​​from the health parameters, it performs differentiated weighted statistics based on quantile distribution to actively assess the health degree that reflects the actual degradation state of the physical block. Based on the health degree, it dynamically adjusts the allowable erase and write count threshold of the physical block, so that physical blocks with better quality can give full play to their remaining value and avoid the waste of lifetime caused by conservative static thresholds.

[0059] In this embodiment, the control unit 20 includes an acquisition module 201, a processing module 202, and an adjustment module 203. The acquisition module 201 is configured to periodically inspect and acquire the health parameters of each storage page within the target physical block in the storage unit 10 when the storage device is idle, thereby obtaining a set of storage page health parameters for the target physical block. The processing module 202 is configured to perform extremum removal processing on the storage page health parameter set and perform differential weighted statistics based on quantile distribution on the processed effective health parameter set to determine the health status of the target physical block. The adjustment module 203 is configured to dynamically adjust the allowable erase / write count threshold of the target physical block in the current state of the storage unit 10 according to a pre-defined mapping relationship between health status and the maximum number of erase / write cycles.

[0060] It should be noted that the storage device provided in this embodiment may also include other conventional functional modules such as an interface controller, a cache unit, and an error correction coding unit. Their specific structure and connection relationships are common knowledge in the art and will not be elaborated here. The innovation of this application lies in the wear leveling processing method executed by the control unit 20. The implementation process of this method will be further described in detail below with reference to the accompanying drawings.

[0061] Figure 2 This is a flowchart illustrating a wear leveling method for a storage device according to one embodiment of this application. Figure 2 As shown, the wear leveling method for storage devices provided in this embodiment specifically includes the following steps:

[0062] Step S201: When the storage device is idle, periodically inspect and obtain the health parameters of each storage page in the target physical block of the storage device to obtain the storage page health parameter set of the target physical block.

[0063] The wear leveling method for storage devices provided in this embodiment is triggered by the control unit during the operation of the storage device. After the storage device powers on and completes initialization, the control unit initiates the execution flow of this wear leveling method while performing routine flash memory management tasks such as address mapping, data read / write, and garbage collection. Considering that performing inspections when the storage device is under heavy read / write load would compete with user data read / write operations for flash interface bandwidth and controller processing resources, leading to increased front-end read / write latency and impacting user experience, this embodiment chooses to trigger the inspection task when the storage device is idle. This utilizes idle resources to assess the physical block health status, achieving isolated execution of front-end performance and back-end management.

[0064] The control unit is configured to inspect target physical blocks according to a preset inspection strategy. This strategy can be flexibly designed based on actual needs. For example, a polling approach can be used to inspect physical blocks sequentially according to their addresses, ensuring that all physical blocks receive periodic evaluations. Alternatively, a priority strategy based on historical health status can be used, giving higher inspection frequencies to physical blocks with lower health levels or potential degradation risks in previous inspections, thus enabling focused monitoring. After selecting a target physical block, the acquisition module performs read operations on all storage pages within that physical block one by one. In conjunction with the error correction coding module, it records the specific values ​​of the health parameters for each storage page during the read process, ultimately summarizing them to form the storage page health parameter set for that physical block.

[0065] In some embodiments, the health parameters include at least one of the following: bit error rate, number of error correction failures, number of rereads, read latency, write latency, and erase latency.

[0066] Bit error rate (BER) refers to the number of erroneous bits detected by the error correction coding unit and compared with the original data when data is read from a memory page. When the oxide layer of a floating gate transistor is intact, the stored electrons can be stably retained, and almost no bit errors occur during reading. As the oxide layer gradually degrades, charge leakage intensifies, causing the decision threshold for some bits to shift during reading, resulting in erroneous bits. Therefore, BER is the most direct indicator reflecting the charge retention capability of a memory cell and the degree of oxide layer degradation.

[0067] Error correction failures refer to the number of times uncorrectable errors occur during the reading of a storage page. Each storage page's redundancy area stores error correction code verification information corresponding to the page's data. When the number of errors exceeds the design limit of the error correction code, the original data cannot be recovered during the read operation, resulting in an error correction failure. Error correction failure is a hallmark event of severe storage page degradation; its occurrence indicates that the reliability of the storage page has dropped to a dangerous level.

[0068] The number of read retries refers to the number of times a read operation fails to complete correctly, requiring adjustment of the flash memory read reference voltage and retrying the read operation. As the oxide layer degrades, the threshold voltage distribution curve of the memory cell gradually widens and drifts towards lower voltages, causing the original default reference voltage to no longer be at the optimal decision position. At this point, the control unit needs to adjust the reference voltage and re-execute the read operation, and only after one or more retries can the correct data be obtained. An increase in the number of read retries directly reflects the severity of the threshold voltage distribution drift.

[0069] Read latency refers to the complete time interval from initiating a page read command to the data being ready for transmission. Write latency refers to the complete time interval from initiating a page programming command to the data being successfully written to the memory cell. Erase latency refers to the time interval from initiating a block erase command to the erase operation being completed. All three latency parameters gradually increase with physical block wear because oxide layer degradation leads to decreased tunneling efficiency, requiring longer programming and erase pulse times to inject or remove charge. Additionally, the read decision circuitry requires a longer settling time.

[0070] The above health parameters reflect the physical state of a physical block from different perspectives. They can be used individually to simplify the collection and calculation complexity, or they can be used in combination to comprehensively evaluate the true health level of the physical block from more dimensions.

[0071] Step S202: Perform extreme value removal processing on the storage page health parameter set to obtain the effective health parameter set of the storage page.

[0072] Considering that during normal use, each storage page within a physical block is subject to various random factors in addition to the systemic impact of oxide layer degradation, such as voltage fluctuations during a single programming operation, read interference from adjacent physical block read / write operations, and sudden increases in local temperature, these random factors may cause occasional anomalies in the health parameters of individual storage pages. This manifests as a significant deviation from the normal levels of most storage pages within the physical block during a single inspection. Directly including these occasionally abnormal storage page health parameters in the statistical calculation is akin to including an incorrectly filled-out answer sheet when calculating a class's average score. This would cause the final statistical result to deviate from the true overall degradation level of the physical block, reducing the accuracy of the health assessment.

[0073] Therefore, after obtaining the set of storage page health parameters, it is necessary to perform extreme value removal. The basic idea of ​​extreme value removal is to arrange all health parameter values ​​in the parameter set in descending or ascending order, making the overall distribution characteristics of the data intuitively visible. Then, according to a preset removal ratio, the data at both ends of the sorted set is excluded, retaining only the majority of data in the middle that stably reflects the overall degradation state of the physical blocks, which is then passed to subsequent steps as a valid health parameter set. The removal ratio can be determined based on the characteristics of flash memory technology and empirical data from actual usage scenarios, ensuring that the removal scope is sufficient to cover the vast majority of accidental abnormal data, while retaining enough data to support the validity of subsequent statistics.

[0074] Step S203: Perform differential weighted statistics based on quantile distribution on the effective health parameter set to determine the health of the target physical block.

[0075] In actual operation, as the wear and tear on physical blocks deepens, the distribution of health parameters among the storage pages within a physical block does not shift synchronously as a whole. Instead, it gradually evolves from a relatively concentrated normal distribution to a significantly skewed distribution. That is, the health parameter values ​​of most storage pages remain concentrated in a relatively low range, but a few heavily worn storage pages have health parameter values ​​significantly higher than the majority distribution. These few high-value storage pages are early signals that the physical block is undergoing irreversible degradation. Compared to the large number of low-value storage pages that are still at a normal level, they have a stronger indicative significance for the overall health status of the physical block and should be given greater attention in statistical evaluation. The traditional approach is to directly calculate the arithmetic mean of the effective health parameter set. However, the arithmetic mean treats all data points equally and cannot distinguish the different indicative significance of different value ranges for the health status.

[0076] To highlight the impact of high-value storage pages in the statistics, this embodiment introduces a differentiated weighted statistical method based on quantile distribution. First, quantile values ​​are calculated based on the data distribution of the effective health parameter set, and the dataset is divided into several different weight intervals according to the quantile values. Then, differentiated weight values ​​are assigned to different weight intervals, so that intervals with higher health parameter values ​​receive greater weight. Finally, the health parameters of each storage page are weighted according to the weight of its corresponding interval to obtain a weighted statistical value that sensitively reflects the degradation trend of physical blocks. This statistical value is determined as the health level of the physical block. Quantiles, as the basis for interval division, have adaptive characteristics and can dynamically determine the interval boundaries based on the actual data distribution of each physical block, without requiring a preset fixed empirical threshold, thus offering greater versatility.

[0077] Step S204: Based on the pre-defined mapping relationship between health status and maximum number of erase / write cycles, dynamically adjust the threshold of the number of erase / write cycles allowed in the current state of the target physical block.

[0078] After determining the current health status of the target physical block in step S203, the control unit further converts it into an executable lifetime management parameter, namely, the maximum number of remaining erase / write cycles that the physical block can safely perform from its current state. This conversion is achieved through a pre-defined mapping relationship that defines the correspondence between health status and the maximum number of erase / write cycles.

[0079] In some embodiments, there is an inverse correlation between health status and maximum rewritable count, and the mapping relationship is pre-stored in the controller of the storage device through a lookup table or piecewise function.

[0080] Generally, the health value is positively correlated with the wear level of the physical block (i.e., the higher the health value, the more severe the wear), while the maximum number of erase / write cycles is negatively correlated with the wear level. Therefore, there is an inverse correlation between health and the maximum number of erase / write cycles. A worse physical block health indicates significant wear and fewer remaining safe erase / write cycles. It should be assigned a stricter erase / write cycle threshold, limiting its use or marking it as unusable after fewer erase / write cycles to prevent data loss due to overuse. Conversely, a better health indicates less wear and a much lower actual degradation rate than conservatively estimated. It should be assigned a higher erase / write cycle threshold, allowing it to continue serving the storage system and fully utilize its remaining value.

[0081] The mapping relationship can be pre-established through accelerated aging tests before the storage device leaves the factory. By collecting health parameters and calculating health status on physical blocks of the same batch at different programming / erasing nodes, the remaining number of erase / write cycles from that node to final failure is recorded synchronously, and a corresponding curve between health status and remaining erase / write cycles is fitted. During the actual operation of the storage device, the control unit, based on the health status calculated in real time in step S203, looks up or calculates the corresponding maximum number of erase / write cycles from this mapping relationship, and updates the allowable erase / write cycle threshold for that physical block accordingly. For heavily worn physical blocks, the threshold may be lowered to hundreds or even lower, providing early warning; for lightly worn physical blocks, the threshold may be raised to thousands, fully exploring their potential value.

[0082] The mapping relationship can be stored in the controller's firmware or dedicated registers in either the form of a lookup table or a piecewise linear function. The lookup table method discretizes the health status into several intervals with a certain step size, each interval corresponding to a preset maximum number of erasable / write cycles. During execution, the health status is directly read as an index. The piecewise linear function method divides the health status value range into several continuous intervals, with each interval using a simple linear relationship to describe the correspondence between the health status and the maximum number of erasable / write cycles. Both methods avoid complex real-time calculations and simplify hardware implementation. The mapping relationship is written at the factory and can be updated during operation based on feedback from step S602.

[0083] Through steps S201 to S204 above, the wear leveling method for storage devices provided in this embodiment actively inspects the health parameters of each storage page within a physical block during idle periods. It eliminates interference from occasional abnormal data by removing extreme values, and then uses differentiated weighted statistics based on quantile distribution to highlight the indicative role of high-value storage pages in degradation assessment. This yields a health score that sensitively reflects the true degradation state of the physical block. Finally, the allowable write / erase count threshold for the physical block is dynamically adjusted based on this health score. This complete closed loop upgrades physical block lifetime management from a traditional, one-size-fits-all static threshold or a coarse-grained mode based solely on write count leveling to a refined, differentiated management mode based on the true health state of the physical block. This allows for the full utilization of high-quality physical blocks while restricting the use of physical blocks at risk of degradation in advance, effectively reducing the risk of data loss and improving the overall durability and data security capabilities of the storage device.

[0084] Figure 3 A flowchart illustrating a wear leveling method for a storage device according to another embodiment of this application. In some embodiments, such as... Figure 3 As shown, in the above embodiment, step S202, which involves removing extreme values ​​from the storage page health parameter set to obtain the effective health parameter set of the storage page, specifically includes the following steps:

[0085] Step S301: Sort the health parameter values ​​in the storage page health parameter set by size.

[0086] Due to the microscopic inhomogeneities in the manufacturing process, historical differences in erase and programming operations, and gradient distributions in local operating temperatures, the degradation levels of individual memory pages within a physical block are not entirely uniform, resulting in naturally discrete health parameter values. Furthermore, the superposition of instantaneous, accidental factors such as voltage fluctuations and read interference can cause the health parameter values ​​of individual memory pages to deviate significantly from the group level in a single inspection. To accurately identify accidental anomalies from this set of discrete and outlier raw data, the parameter values ​​must first be sorted according to their magnitude. The sorting operation reorganizes the originally disordered data into an ordered sequence from minimum to maximum value, making the central tendency, dispersion, and the presence of obvious outliers immediately apparent. After sorting, low-value accidental anomalies naturally converge at the head of the sequence, while high-value accidental anomalies naturally converge at the tail, facilitating subsequent proportional removal of interfering items.

[0087] Step S302: Based on the preset first ratio and second ratio, remove the header data of the first ratio and the tail data of the second ratio from the storage page health parameter set to obtain the valid health parameter set of the storage page.

[0088] Considering that abnormal data usually appears at both ends of the sorted sequence, based on the ordered sequence after sorting in step S301, the control unit removes data from both ends of the sorted sequence according to a preset ratio. Specifically, a first ratio is used to determine the amount of low-value data to remove from the head of the sorted sequence, and a second ratio is used to determine the amount of high-value data to remove from the tail of the sorted sequence. The head of the sorted sequence contains the data with the smallest health parameter values, and the tail contains the data with the largest health parameter values.

[0089] The first proportion of data removed from the top of the dataset is to exclude abnormally low values ​​caused by individual storage pages that have not been fully programmed or have been in a static data retention state for a long time. Although these abnormally low values ​​are few in number, if included in the statistics, they will have a dilution effect, lowering the true health indicator values. Especially when physical blocks show early signs of degradation, the warning signals emitted by a few high-value storage pages may be masked by a large number of normal low values, and the further lowering effect of abnormally low values ​​will exacerbate this dilution effect, reducing the sensitivity and timeliness of health assessments. The second proportion of data removed from the bottom of the dataset aims to exclude single abnormally high values ​​caused by factors such as sudden defects in local storage units, transient read interference, or accidental fluctuations in programming operations. If these abnormally high values ​​are included in subsequent statistical calculations, they will significantly inflate the overall health indicator, causing the health status of physical blocks to be misjudged as worse than it actually is, resulting in the premature restriction or marking of still-good-quality physical blocks as bad blocks, causing unnecessary waste of their remaining lifespan.

[0090] Through the above extreme value removal process, the effective health parameter set eliminates the dual interference of random low values ​​at the head and random high values ​​at the tail. The distribution characteristics of its internal data can more realistically and stably reflect the overall degradation level of the physical block at the current wear stage, providing high-quality basic data for the differential weighted statistics based on quantile distribution in the subsequent step S203.

[0091] In a preferred embodiment, the first and second ratios are set within a range of 3% to 10%, allowing for the selection of appropriate ratios based on the flash memory chip's process characteristics, storage density, and application scenario. For example, for flash memory chips with moderate storage density and good cell consistency, in typical flash memory health parameter distributions such as bit errors, over 95% of the storage page health parameters are concentrated within a certain range near the mean, and outliers truly caused by accidental factors typically account for no more than 5% of the total. In this case, both the first and second ratios can be set to 3%, meaning that the top 3% of data with the smallest values ​​and the bottom 3% of data with the largest values ​​are removed after sorting, retaining the middle 94% of the data as the effective health parameter set. Removing 3% from each side is sufficient to cover the vast majority of anomalies, while retaining over 90% of the data volume to support the effectiveness and reliability of subsequent statistical calculations. For flash memory chips with higher storage density, poorer cell consistency, or more dispersed bit error distribution, the above ratios can be appropriately increased to 5% or even 10% to enhance the ability to exclude a wider range of anomalies and ensure the representativeness and stability of the effective health parameter set.

[0092] Figure 4 A flowchart illustrating a wear leveling method for a storage device according to another embodiment of this application. In some embodiments, such as... Figure 4 As shown, in the above embodiment, step S203, which involves performing differential weighted statistics based on quantile distribution on the effective health parameter set to determine the health of the target physical block, specifically includes:

[0093] Step S401: Determine at least one quantile value for the weight interval used to divide the effective health parameter set.

[0094] After de-extreme value processing, the effective health parameter set eliminates accidental outliers, and its distribution characteristics can more realistically reflect the health status distribution of each storage page within a physical block under the combined effects of systemic degradation and process differences. To differentiate and weight these data, it is first necessary to determine the boundary values ​​for dividing different weight intervals.

[0095] This embodiment uses quantiles as the boundary delineation tool. The selection of quantiles is based on the distribution characteristics of the data itself and has adaptive capabilities. As physical block wear intensifies, the overall distribution of the effective health parameter set gradually shifts to the right and lengthens its right tail. At this time, the quantile values ​​will dynamically adjust with the changes in data distribution, automatically adapting to the distribution pattern of different degradation stages and maintaining the relative proportion of data in each interval. Compared with using fixed numerical thresholds, this eliminates the need to preset different thresholds for different flash memory batches or different degradation stages, resulting in greater versatility and adaptability.

[0096] The number of quantiles can be flexibly selected based on the system's requirements for health assessment accuracy and hardware implementation complexity. The simplest approach is to choose one quantile, such as the median, to divide the effective health parameter set into two weighted intervals: a low-value interval and a high-value interval, corresponding to the normal and degenerative states, respectively. This two-interval approach has the simplest hardware implementation, requiring only one comparator and two counters. A slightly more precise approach involves choosing two quantiles, such as the 25th and 75th quantiles, to divide the dataset into three weighted intervals: a low-value interval, a median interval, and a high-value interval. These two quantiles are classic quartiles in statistics, effectively distinguishing the middle and extremes of the distribution, balancing discriminative power and implementation complexity. In applications requiring finer weight gradients, three or more quantiles can be selected to divide the data into four or more weighted intervals, achieving a smoother weight transition.

[0097] Step S402: Assign corresponding weights to the divided weight intervals, where the weight interval with the larger health parameter value has a larger corresponding weight.

[0098] After determining the boundary points of each weight interval in step S401, it is necessary to specify the weight coefficient for each interval in the statistical calculation. The general principle of weight allocation is: the interval with the higher the health parameter value should be given more attention in health statistics, and therefore should be assigned a larger weight.

[0099] Let's take the case of dividing two quantile values ​​into three weighted intervals as an example. Let these be the first, second, and third intervals, from lowest to highest. The first interval gathers the memory pages with the lowest health parameter values ​​in the effective health parameter set. These memory pages are in good condition, and their physical degradation characteristics are not yet obvious. Their health parameter values ​​mainly reflect the basic background level of the physical block. The second interval contains most of the memory pages at the intermediate level, representing the normal fluctuation range of the physical block at its current stage. The third interval gathers the memory pages with the highest health parameter values. The physical degradation of these memory pages is significantly higher than that of most of their peers within the physical block, and they are the focus of attention.

[0100] To highlight the contribution of high-value memory pages in the third interval to health assessment, the weights of each interval should follow an increasing relationship: the first interval has the smallest weight, the second interval has a moderate weight, and the third interval has the largest weight. A preferred weight ratio is approximately 1:2:4, meaning the weight of the first interval is approximately 1, the second interval has approximately 2, and the third interval has approximately 4. This ratio reflects a proportional increase and effectively amplifies the impact of high-value memory pages in the statistics. The specific absolute values ​​of the weights can be calibrated and fine-tuned within a certain range based on mass production experimental data. For example, the weight of the first interval can be selected between 0.5 and 1.0, the weight of the second interval between 1.5 and 2.5, and the weight of the third interval between 3.5 and 4.5. A fixed constant value is ultimately selected for each interval and written into the controller's register for runtime use. The proportional or approximately proportional weight design also has a hardware implementation advantage: the weight values ​​can be multiplied by shifting and adding the health parameter values. For example, multiplying by weight 2 can be achieved by shifting left by one bit, multiplying by weight 4 can be achieved by shifting left by two bits, and multiplying by weight 0.5 can be achieved by shifting right by one bit. The entire process does not require the use of complex hardware multipliers, which reduces the chip area and power consumption of the control unit.

[0101] The choice of the number of quantiles can be a trade-off between hardware complexity and statistical accuracy. A single quantile scheme is the simplest to implement in hardware, a two-quantile scheme provides good discrimination while moderately increasing complexity, and a three- or higher quantile scheme is suitable for applications requiring higher accuracy. When using only one quantile to divide the data into two intervals, the weight of the higher-value interval should be significantly greater than that of the lower-value interval, such as setting a weight ratio of approximately 1:3 or 1:4. When using three or more quantiles to divide the data into four or more intervals, a progressively increasing weight sequence can be used to achieve a smoother gradient.

[0102] Step S403: Calculate the weighted statistical value as the health of the target physical block based on the health parameters and the weight values ​​of their respective weight intervals.

[0103] After determining the weight interval and corresponding weight value of each storage page's health parameter, the health of the target physical block is calculated. For each health parameter value in the valid health parameter set, it is determined which weight interval it falls into, and the corresponding weight coefficient is obtained. Then, the parameter value is multiplied by its weight coefficient, and these are accumulated into a weighted sum. Simultaneously, the weight coefficient is accumulated into the total weighted sum. After traversing all health parameters, the weighted sum is divided by the total weighted sum to obtain the weighted average, which is the health of the physical block.

[0104] Because storage pages with higher health parameter values ​​are assigned greater weight, when physical blocks are in good condition, the health parameters of most storage pages are concentrated in the low value range. Even if a few storage pages have slightly higher values, these are diluted by their smaller weights, keeping the statistical value at a low level. When physical blocks begin to degrade, the health parameters of some storage pages break out of their original distribution range, enter the high value range, and are multiplied by a larger weight, causing the weighted statistical value to rise rapidly, sensitively reflecting early degradation signals. Once degradation continues to worsen, more and more storage pages enter the high value range, and the statistical value will continue to climb, driving subsequent threshold adjustments.

[0105] In some embodiments, when only one health parameter is selected, step S403 involves calculating a weighted statistical value as the health of the target physical block based on the health parameter and the weight value of its corresponding weight range. The specific calculation process is as follows:

[0106] Suppose that the set of valid health parameters contains M health parameter values, which can be denoted as follows according to the storage page order: The aforementioned M health parameter values ​​have undergone extreme value processing, eliminating interference from accidental outliers. Based on at least one quantile value determined in step S401, these M data points can be divided into corresponding weight intervals. According to step S402, the weight values ​​corresponding to each weight interval have been preset in the controller. For the i-th health parameter value... It is compared with each quantile value to determine the weight interval into which it falls, and the weight value corresponding to that interval is obtained. The weighted statistical value S, which is the health of the physical block, is calculated using the following formula:

[0107] ;

[0108] The numerator is the sum of each health parameter value multiplied by its corresponding weight, and the denominator is the sum of each weight value. The division operation is to divide the weighted sum by the weighted sum to obtain the final weighted average. The health parameter value with the larger weight contributes more to the final statistical value S, thus amplifying the influence of high-value parameters.

[0109] In practical implementation, the comparison operation, which compares each health parameter value with the quantile value to determine its interval, can be implemented using a hardware comparator; the weighted multiplication, since the weight values ​​are designed to be powers of 2 or simple combinations thereof, can be implemented using shift and addition; the cumulative summation is implemented using an accumulator; and the single division is implemented using a divider or reciprocal multiplication. The overall hardware implementation has low complexity and is suitable for efficient execution in embedded environments of storage device control units.

[0110] Figure 5 This is a flowchart illustrating a wear leveling method for a storage device according to another embodiment of this application. Figure 5As shown, in other embodiments, when multiple health parameters are selected, step S403 calculates a weighted statistical value as the health of the target physical block based on the health parameters and their respective weight intervals. The specific calculation process is as follows:

[0111] Step S501: Calculate the weighted average value corresponding to each health parameter based on the weight value of each health parameter and its corresponding weight range.

[0112] When the health parameters collected in step S201 are not limited to one type, but multiple health parameters are acquired simultaneously, the aforementioned complete extreme value removal and quantile weighted statistical process needs to be performed on each health parameter separately. For example, if two health parameters, bit error rate and read delay time, are collected simultaneously, then the quantile value determination in step S401, the weight interval division and weight allocation in step S402, and the aforementioned single-parameter weighted statistical value calculation formula are performed on the effective health parameter sets of each parameter respectively, ultimately obtaining the weighted average value of bit error rate. Weighted average of read latency The calculation process for the weighted average of each single parameter is exactly the same as that for the single health parameter scenario mentioned above. The only difference is that the input parameter data is replaced with multiple types, which are then executed independently in sequence.

[0113] Step S502: Based on the normalized reference base value corresponding to each health parameter, normalize the weighted average value corresponding to each health parameter to obtain the normalized feature value corresponding to each health parameter.

[0114] Because the dimensions and dynamic ranges of different health parameters vary significantly—for example, the number of bit errors may vary from single digits to hundreds over the entire lifespan of a physical block, while read latency, typically measured in microseconds, may vary from tens to hundreds of microseconds—if the weighted average of hundreds of bit errors is directly added to the weighted average of tens of read latency, the number of bit errors will completely dominate the final result, while the information provided by read latency will be lost. Therefore, after obtaining the weighted average of each health parameter in step S501, it is necessary to normalize the weighted average corresponding to each health parameter.

[0115] A normalized reference base value is preset for each health parameter. This base value represents the typical value of the parameter when the physical block is nearing the end of its lifespan, or a standardized reference value determined by testing. For example, based on accelerated aging test data of the same batch of flash memory, the typical value of bit error rate is about 200 and the typical value of read latency is about 100 microseconds when the physical block is at critical reliability failure. Therefore, the normalized reference base value for bit error rate is set to 200, and the normalized reference base value for read latency is set to 100. The weighted average value of each parameter obtained in step S501 is divided by its respective normalized reference base value to obtain the dimensionless normalized characteristic value. After normalization, the normalized characteristic values ​​of each parameter fall within a similar numerical range, usually between 0 and 1 or slightly greater than 1, achieving comparability between parameters with different dimensions and providing a unified numerical basis for subsequent fusion and weighting.

[0116] Step S503: Calculate the weighted statistical value as the health of the target physical block based on the normalized feature value corresponding to each health parameter and its fusion weight to the health of the target physical block.

[0117] After converting the weighted average of each health parameter into dimensionless, normalized eigenvalues ​​with matching numerical ranges in step S502, they need to be merged into a unified comprehensive health score. Different health parameters do not have entirely the same reference value for assessing the physical block's health status. For example, bit error rate and reread count directly reflect the charge retention capability and threshold voltage drift of the memory cell, and are most closely related to the physical degradation mechanism of the physical block, thus having higher reference value. Read / write latency, in addition to being affected by oxide layer degradation, is also affected by external factors such as flash memory interface activity and ambient temperature, making its reference value relatively lower. To reflect the differences in the reference value of different parameters, a fusion weight is assigned to each health parameter. The magnitude of the fusion weight reflects the degree to which the parameter contributes to the final comprehensive health score. The stronger the correlation and the more directly it reflects the essence of physical degradation, the larger the fusion weight. The comprehensive health score is obtained by weighted summation using the normalized eigenvalues ​​of each parameter and the fusion weight.

[0118] The comprehensive health score integrates physical block degradation information reflected from different dimensions by multiple health parameters. It eliminates random anomalies through extreme value removal, amplifies the indicative role of high-value data through quantile weighting, eliminates dimensional differences through normalization, and finally integrates the comprehensive diagnostic value of each parameter through fusion weights. It can assess the true health status of physical blocks more comprehensively and accurately than a single parameter, and has stronger robustness.

[0119] In a specific embodiment, suppose a total of K health parameters are collected. For the k-th health parameter (k=1,2,...,K), the number of valid data points remaining after extreme value removal is: The parameter values ​​for each data point are denoted as According to step S401, the quantile value corresponding to the parameter is determined and the weight interval is divided. According to step S402, the corresponding weight is assigned to each data point. .

[0120] (1) Calculation of single-parameter weighted average

[0121] For each health parameter, calculate the weighted average of its valid dataset. The weighted average of the k-th health parameter... Calculate using the following formula:

[0122] ;

[0123] The numerator is the sum of each data point parameter value multiplied by its corresponding weight, and the denominator is the sum of all weights. This formula is completely consistent with the weighted statistical value calculation formula for the single health parameter scenario mentioned above. Applying this formula to K different health parameters yields a total of K single-parameter weighted averages. .

[0124] (2) Normalization

[0125] Preset a normalized reference base value for each health parameter. The weighted averages are calculated. Divide by its corresponding normalized reference base value The dimensionless normalized eigenvalues ​​are obtained. : .

[0126] After this division operation, the statistical values ​​of various health parameters with different dimensions and numerical ranges are uniformly mapped to a similar numerical space, usually within the range of 0 to 1 or slightly greater than 1, thus making them comparable.

[0127] (3) Multi-parameter fusion weighting

[0128] Preset fusion weights for each health parameter Each fusion weight satisfies the normalization condition. ,Right now Utilizing the normalized eigenvalues ​​of each parameter and fusion weight Calculate overall health :

[0129] ;

[0130] The result obtained in step (2) through step (1) By substituting the values, the overall health of the target physical block can be calculated.

[0131] This involves a complete mathematical processing procedure from the raw multi-parameter data, including extremum removal, quantile weighting, normalization, and weighted fusion, ultimately outputting a unified comprehensive health score. The health of the target physical block is then used for the threshold mapping step in the subsequent step S204.

[0132] This comprehensive health score integrates multi-dimensional health information, utilizing the diagnostic capabilities of each parameter in its respective professional context. It also eliminates dimensional differences through normalization and reflects the differences in comprehensive diagnostic value of different parameters through fusion weights. The final value can more comprehensively and accurately assess the true degradation state of physical blocks than a single parameter, and is more robust.

[0133] Figure 6 This is a flowchart illustrating a wear leveling method for a storage device according to another embodiment of this application. Figure 6 As shown, in some embodiments, after calculating the health of the target physical block, the wear leveling method for the storage device further includes the following steps:

[0134] Step S601: Record the historical trend of the health status of the target physical block.

[0135] During continuous operation, the control unit performs a complete health assessment on the target physical block at each inspection cycle, generating a health value for that moment. The control unit records the latest health value generated from each inspection along with the number of times the physical block has been erased and rewritten, forming a health history sequence for that physical block. The health history can be stored in a few bytes in the physical block metadata area, cyclically overwriting the oldest record to save storage space; or it can be stored in the control unit's reserved management storage area or system memory.

[0136] As usage time increases and inspection cycles accumulate, this historical record sequence will gradually become denser, outlining the trajectory of the target physical block's health as the number of erases and writes increases. By analyzing the changing patterns of this trajectory, it is possible to understand whether the physical block's degradation rate is constant, accelerating, or slowing down, and whether its actual degradation rate is faster or slower than the nominal degradation rate based on sample testing at the factory.

[0137] Step S602: Update the pre-defined mapping relationship between health status and maximum number of erasable / rewrite cycles based on historical trends.

[0138] In the above embodiments, step S204, which dynamically adjusts the allowable erase / write count threshold of the target physical block in its current state, is based on a pre-defined mapping relationship between health and the maximum number of erase / write cycles. This mapping relationship is obtained by conducting accelerated aging tests on a limited number of samples from the same batch before the storage device leaves the factory and is uniformly burned into all devices. This process is a general mapping based on statistical samples, reflecting the average degradation characteristics of the flash memory in that batch under standard test conditions. However, after the device is put into use, due to individual factors such as actual workload characteristics, ambient temperature variation range, and slight differences in the power supply voltage within each device, the actual degradation trajectory of the device may deviate from the factory-preset average mapping.

[0139] Therefore, the historical trend data of the physical block's health accumulated in step S601 can be used to dynamically and individually correct the factory-preset mapping relationship. For example, if the physical block's health value is consistently better than the expected health value corresponding to that number of erases in the factory mapping relationship when experiencing the same number of erases, it indicates that the actual regression speed of the physical block is slower than the factory-calibrated average value. In this case, the mapping relationship can be adjusted to be more lenient, assigning a higher allowable number of erases to that health level. Conversely, if the historical trend shows that the physical block's health declines faster than expected, the mapping relationship can be tightened, setting a stricter threshold for the number of erases for the same health level.

[0140] Updating the mapping relationship can be implemented in various ways. These include, but are not limited to, scaling the output value of the overall mapping function, incrementing or decrementing the offset of some entries in the lookup table, or fitting the health of the physical block to the failure curve online and then replacing the original mapping. Updates can be performed independently on a single physical block to support each physical block maintaining its own exclusive mapping relationship; alternatively, the trends of multiple physical blocks in the same batch can be combined for smoothing before updating to avoid noise introduced by the accidental behavior of a single block.

[0141] By updating historical data, the mapping relationship can be gradually evolved from a general average value at the time of manufacture to a proprietary mapping that adapts to the actual individual degradation characteristics of each physical block, thus realizing the self-optimization and continuous evolution of the life management strategy.

[0142] Figure 7 This is a flowchart illustrating a wear leveling method for a storage device according to another embodiment of this application. Figure 7 As shown, in some embodiments, after calculating the health of the target physical block, the wear leveling method for the storage device further includes the following steps:

[0143] Step S701: Based on the health status of each physical block, classify the health levels of multiple physical blocks in the storage device.

[0144] During normal operation of storage devices, not just one physical block is evaluated per inspection. Over time, most physical blocks in the storage unit accumulate their own health assessment results. After collecting the latest health values ​​of each physical block, all physical blocks are divided into different health level ranges based on several preset health thresholds. For example, three thresholds can be set to divide the system into four health levels: Good, Normal, Warning, and Dangerous. The physical block with the lowest health value and the slightest degradation is classified as Good; those with a slightly increased health value are classified as Normal; those with a high health value and obvious signs of degradation are classified as Warning; and those with a very high health value, approaching the failure threshold, are classified as Dangerous. The number of health levels and the thresholds between each level can be preset according to the storage device's data security requirements and the granularity of the data allocation strategy.

[0145] Step S702: Adjust the data allocation strategy for each physical block according to the health level.

[0146] After obtaining the health level classification results for each physical block, the data write allocation strategy of the storage device can be adjusted accordingly. The adjustment process follows the principle of prioritizing data writing to physical blocks with higher health levels and restricting or stopping the writing of new data to physical blocks with lower health levels. Specifically, for physical blocks with good and normal health levels, normal write allocation is maintained, and the write load can be evenly distributed among these physical blocks according to the traditional write wear leveling strategy to keep their erase and write cycles relatively balanced. For physical blocks with a warning level, their priority in write allocation is reduced, decreasing the probability of new write tasks being assigned to these blocks, slowing down their wear rate, and they are listed as priority inspection targets with shorter inspection cycles to closely monitor their status changes. For physical blocks with a dangerous health level, no new write tasks are assigned to them, and the valid data already stored inside is migrated to physical blocks with good or normal health levels. After the migration is completed, they are removed from the available physical block pool or marked as pending reclamation.

[0147] Traditional wear leveling only pursues uniformity in terms of write count, without considering the actual physical state differences of each physical block due to process variations under the same write count. This embodiment's health-level-based data allocation strategy effectively complements and enhances traditional wear leveling methods. By introducing health levels, health-level screening is performed before write count leveling, filtering out physical blocks with poor health conditions. Write count leveling is only performed within physical blocks of the same health level, achieving fine-grained storage management in two dimensions.

[0148] Figure 8 This is a flowchart illustrating a wear leveling method for a storage device according to another embodiment of this application. Figure 8As shown, in some embodiments, after adjusting the allowable erase / write count threshold for the current state of the target physical block, the wear leveling method for the storage device further includes the following steps:

[0149] Step S801: Obtain the current number of erase / write operations for the target physical block.

[0150] The erase / write count counter for a physical block is maintained by the control unit. Each time an erase operation is performed on the physical block, the corresponding counter is incremented by one. The value of this counter is stored in the physical block's metadata area or in the management data table within the controller, serving as a reference for functions such as wear leveling and bad block management. The control unit can obtain the total number of erase / write cycles the target physical block has undergone since its manufacture or last replacement by reading the current value of this counter.

[0151] Step S802: When the current number of erase / write cycles reaches or exceeds the adjusted allowed number of erase / write cycles threshold, mark the target physical block as an unusable block.

[0152] Before each erase operation on the physical block, or after each inspection and update of the allowed erase / write count threshold for the physical block, the current erase / write count obtained in step S801 is compared with the current allowed erase / write count threshold dynamically adjusted and written in step S204. When the erase / write count is less than the threshold, the physical block is still within a safe range and can continue to be used; when the erase / write count reaches or exceeds the threshold, it indicates that the physical block has exhausted its reserved safety lifetime margin in its current actual health state, and continued use will face a significantly increased risk of data errors. At this time, the control unit marks the physical block as an unusable block. The unusable block marking information is written to the metadata management area of ​​the physical block and the bad block management table of the control unit. Subsequently, in the address mapping and space allocation stages, the physical block will be excluded from the candidate set of available physical blocks, and new user data will no longer be written. For the valid user data still stored in the physical block, the control unit will initiate a data migration or garbage collection process at an appropriate time to transfer it to other healthy and available physical blocks, thus completing data preservation.

[0153] Through steps S801 to S802, this embodiment forms a complete closed loop from health assessment to threshold adjustment and finally execution limit, ensuring that each physical block is stopped from use in a timely and decisive manner when its actual lifespan is close to the limit, and avoiding data storage on media with unreliable data.

[0154] In summary, the wear leveling method for storage devices provided in the above embodiments actively inspects and acquires the health parameters of each storage page within a physical block when the storage device is idle. After removing extreme values ​​to eliminate interference from occasional abnormal data, the processed data is then differentially weighted based on quantile distribution, giving data with higher health parameter values ​​a greater statistical weight. This results in a health score that sensitively reflects the true degradation state of the physical block, and the allowable write / erase count threshold for the physical block is dynamically adjusted based on this health score, achieving differentiated lifetime management for different physical blocks. Compared to the coarse management mode of using fixed thresholds or only based on write count leveling in existing technologies, this method can perform fine-tuning according to the actual physical degradation degree of each physical block, allowing physical blocks with better quality to have their service life extended, while restricting the use of physical blocks with early signs of degradation in advance, effectively avoiding the risk of data loss due to excessive wear. By feeding back the historical trend of health score changes to the continuous update of the mapping relationship, it has the ability to adaptively optimize, allowing the lifetime management strategy to continuously adapt to the individual physical characteristics of the device during actual use, significantly improving the overall durability and data security of the storage device.

[0155] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement various processes of any embodiment of the wear leveling method for the storage device described above, and can achieve the same technical effect. To avoid repetition, they will not be described again here.

[0156] The processor can be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0157] In the above embodiments, implementation can be achieved, in whole or in part, by software, hardware, firmware, or any combination thereof. Furthermore, as those skilled in the art will understand, the principles herein can be reflected in a computer program product on a computer-readable storage medium pre-loaded with computer-readable program code. Any tangible, non-transitory computer-readable storage medium may be used, including magnetic storage devices (hard disks, floppy disks, etc.), optical storage devices (CDs, DVDs, Blu-ray discs, etc.), flash memory, and / or the like. These computer program instructions can be loaded onto a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to form a machine, such that instructions executing on the computer or other programmable data processing apparatus can generate means for performing a specified function. These computer program instructions can also be stored in a computer-readable storage medium that can instruct the computer or other programmable data processing apparatus to operate in a particular manner, such that instructions stored in the computer-readable storage medium can form an article of manufacture, including means for implementing the specified function. The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to perform a series of operational steps on the computer or other programmable apparatus to produce a computer-implemented process, such that instructions executing on the computer or other programmable apparatus can provide steps for implementing the specified function.

[0158] This document describes various exemplary embodiments with reference to them. However, those skilled in the art will recognize that changes and modifications can be made to the exemplary embodiments without departing from the scope of this document. For example, various operational steps and components for performing operational steps can be implemented in different ways depending on the specific application or considering any number of cost functions associated with the operation of the system (e.g., one or more steps can be deleted, modified, or combined with other steps).

[0159] While the principles herein have been illustrated in various embodiments, numerous modifications to the structures, arrangements, proportions, elements, materials, and components, particularly suited to specific environments and operational requirements, may be used without departing from the principles and scope of this disclosure. These modifications and other alterations or alterations will be included within the scope of this document. Those skilled in the art will recognize that many changes can be made to the details of the above embodiments without departing from the fundamental principles of the invention.

Claims

1. A wear leveling method for a storage device, characterized in that, include: When the storage device is idle, periodic inspections are performed to obtain the health parameters of each storage page in the target physical block of the storage device, thereby obtaining the storage page health parameter set of the target physical block; The storage page health parameter set is subjected to extreme value removal processing to obtain the effective health parameter set of the storage page; The health of the target physical block is determined by performing differential weighted statistics based on quantile distribution on the set of effective health parameters. Based on the pre-defined mapping relationship between health status and maximum number of erase / write cycles, the threshold for the number of erase / write cycles allowed in the current state of the target physical block is dynamically adjusted.

2. The wear leveling method for storage devices according to claim 1, characterized in that, The health parameters include at least one of the following: bit error rate, number of error correction failures, number of rereads, read latency, write latency, and erase latency.

3. The wear leveling method for storage devices according to claim 1, characterized in that, The process of removing extreme values ​​from the storage page health parameter set includes: Sort the health parameter values ​​in the storage page health parameter set by size; Based on a preset first ratio and a second ratio, the header data of the first ratio and the tail data of the second ratio in the storage page health parameter set are removed to obtain the effective health parameter set of the storage page.

4. The wear leveling method for storage devices according to claim 1, characterized in that, The step of performing differential weighted statistics based on quantile distribution on the effective health parameter set to determine the health of the target physical block includes: Determine at least one quantile value for the weight interval used to divide the effective set of health parameters; Assign corresponding weights to the divided weight intervals, where the weight interval with the larger health parameter value has a larger corresponding weight; The health of the target physical block is calculated based on the health parameters and their respective weight ranges.

5. The wear leveling method for a storage device according to claim 4, characterized in that, When the health parameters include multiple parameters, the step of calculating a weighted statistical value as the health of the target physical block based on the health parameters and their respective weight intervals includes: Calculate the weighted average value corresponding to each health parameter based on the weight value of each weight interval to which it belongs; Based on the normalized reference base value corresponding to each of the health parameters, the weighted average value corresponding to each of the health parameters is normalized to obtain the normalized feature value corresponding to each of the health parameters. Based on the normalized feature value corresponding to each health parameter and its fusion weight to the health of the target physical block, a weighted statistical value is calculated as the health of the target physical block.

6. The wear leveling method for a storage device according to claim 1, characterized in that, The health status is inversely correlated with the maximum number of erasable and rewritable cycles, and the mapping relationship is pre-stored in the controller of the storage device through a lookup table or a piecewise function.

7. The wear leveling method for a storage device according to claim 6, characterized in that, Also includes: Record the historical trend of the health status of the target physical block; Based on the historical trend, update the mapping relationship between the pre-calibrated health status and the maximum number of erasable and rewritable cycles.

8. The wear leveling method for a storage device according to claim 1, characterized in that, Also includes: Based on the health status of each physical block, the health levels of multiple physical blocks in the storage device are classified. Adjust the data allocation strategy for each physical block according to the health level; And / or, obtain the current number of erase / write operations on the target physical block; When the current number of erase / write operations reaches or exceeds the adjusted allowed number of erase / write operations threshold, the target physical block is marked as an unusable block.

9. A storage device, characterized in that, include: A storage unit includes multiple physical blocks, and each physical block includes multiple storage pages; The control unit includes an acquisition module, a processing module, and an adjustment module; The acquisition module is configured to periodically inspect and acquire the health parameters of each storage page in the target physical block of the storage unit when the storage device is idle, so as to obtain the storage page health parameter set of the target physical block; The processing module is configured to perform extremum removal processing on the storage page health parameter set, and perform differential weighted statistics based on quantile distribution on the processed effective health parameter set to determine the health of the target physical block; The adjustment module is configured to dynamically adjust the threshold of the number of erase / write cycles allowed for the target physical block in the storage unit under the current state, based on a pre-defined mapping relationship between health and maximum number of erase / write cycles.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer-executable program or instructions, which, when executed by a processor, are used to implement the wear leveling processing method of the storage device as described in any one of claims 1 to 8.