Solid state disk write leveling optimization method

By calculating wear difference indices and dividing intervals by logical address in solid-state drives (SSDs), the problem of failing to accurately identify local wear in existing technologies is solved. This reduces write amplification and performance jitter without moving data pages, thereby improving the lifespan and stability of SSDs.

CN121979460BActive Publication Date: 2026-06-26HUIRONG ELECTRONIC SYST ENG CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUIRONG ELECTRONIC SYST ENG CO LTD
Filing Date
2026-03-30
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing solid-state drive write balancing optimization methods fail to accurately identify local hot spots or local cold data distributions, resulting in the inability to intervene in a timely manner when local wear is severe but overall statistical indicators have not yet been triggered. Furthermore, they rely on data migration, leading to performance fluctuations and write amplification, and lack fine-grained hierarchical strategies and consistency design for logical intervals.

Method used

The wear difference index is used to trigger leveling. The interval is divided according to logical address. Candidate cold logical intervals of high wear blocks and low wear blocks are selected. The physical page set is swapped without moving user data pages by updating the mapping table. The swap lock flag and log record are set to ensure consistency and reliability.

Benefits of technology

It reduces write amplification and performance jitter without moving user data pages, improves flash memory lifespan utilization, and ensures mapping consistency and system stability under abnormal conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121979460B_ABST
    Figure CN121979460B_ABST
Patent Text Reader

Abstract

The present application relates to a solid state disk write balancing optimization method, applied to a solid state disk containing a controller and a flash memory medium, the controller maintaining a logical address to physical page mapping table and erase count information; comprising: calculating the difference between the maximum and minimum erase counts of each erase block in a predetermined statistical range as a wear difference indicator; dividing the logical address into logical intervals, if a certain logical interval does not occur in the mapping failure update event within the time window, it is determined as a candidate cold logical interval; selecting a first candidate cold logical interval mapped to a high wear block and a second candidate cold logical interval mapped to a low wear block; without moving existing valid user data pages, only by updating the physical page set identifier or interval descriptor used for subsequent writing of the first and second candidate cold logical intervals in the mapping table, exchanging the physical page sets corresponding to the first and second candidate cold logical intervals; the mapping table update record and related block state are written in a log mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of memory control and data management technology, specifically a method for optimizing write balancing in solid-state drives. Background Technology

[0002] Currently, SSD write balancing optimization methods mainly focus on adjusting the overall wear leveling intensity based on erase count statistics. The core idea is to obtain the erase count of each storage cell, calculate the median and mean, and adjust the dynamic or static wear leveling intensity based on the difference between the two. The decision to enter the wear leveling adjustment process is based on whether the median erase count exceeds an empirical threshold, and the number of storage cells participating in balancing is adjusted according to the absolute value of the difference between the median and the mean, thus achieving a trade-off between performance and lifespan. This approach has some adjustment capability at the overall wear distribution statistical level, but its technical path is still limited to block-level statistics and intensity control. As can be seen from patent document CN117275561A, it mainly addresses how to adjust the balancing intensity, without delving into the logical mapping level for structural optimization. Firstly, this method relies on global statistical results as the triggering basis. When the median erase count does not reach the empirical threshold, it directly returns to re-statistics, lacking the ability to finely identify local hot spots or local cold data distributions. This may prevent timely intervention when local wear is severe but overall statistical indicators have not yet triggered, causing individual blocks to reach their lifespan limit prematurely.

[0003] Secondly, this scheme essentially still relies on selecting more or fewer storage units to participate in dynamic or static wear leveling to achieve balance adjustment. This adjustment method still requires block-level data migration through data relocation or garbage collection mechanisms. Data relocation inevitably brings additional write amplification and performance overhead, which may cause performance fluctuations, especially during peak load periods. Furthermore, the strategy of flexibly adjusting the combination of dynamic and static wear leveling based on the positive or negative difference, as described in this method, is still based on the distribution of erase counts at the block level. It does not involve optimizing the mapping structure at the logical interval level, nor does it consider redistributing wear through mapping table structure reconstruction without relocating valid user data pages. Therefore, it still has limitations in reducing write amplification.

[0004] Furthermore, the core control of this scheme is the difference between the median and mean of the number of erases, which is a statistical distribution adjustment. Its focus is on whether the distribution is close to normal or concentrated. However, this statistical control cannot precisely locate the relationship between specific logical data regions and physical blocks, and lacks a mechanism to identify continuous logical address intervals, data hot / cold characteristics, and mapping failure update behavior. Therefore, it is difficult to perform targeted scheduling based on the update frequency differences of different logical intervals. The handling of high-frequency update areas and long-term static areas still relies on traditional dynamic and static balancing mechanisms, without providing a fine-grained layering strategy at the logical interval level. While this method improves statistical efficiency by accelerating the calculation of the median and variance through hardware, its optimization direction still focuses on improving statistical computation efficiency, without changing the fundamental data movement-dependent balancing operation. Regarding power-down consistency, this paper also does not address mechanisms such as log persistence, atomic updates of mapping tables, or swap locking control. It cannot guarantee accurate rollback or replay of mapping relationships when encountering abnormal situations during balancing execution. Reliability still relies on conventional FTL recovery mechanisms, lacking a dedicated consistency design for balancing operations. Summary of the Invention

[0005] The purpose of this invention is to provide a solid-state drive write balancing optimization method to solve some of the drawbacks and shortcomings pointed out in the background art.

[0006] The present invention addresses the aforementioned technical problems by employing the following technical solution: applied to a solid-state drive containing a controller and flash memory media, wherein the controller maintains a logical address to physical page mapping table and erase / write count information, including:

[0007] Wear difference determination steps: Calculate the difference between the maximum and minimum number of erase / write times for each erase block within a predetermined statistical range as the wear difference index. When the wear difference index is not less than the first threshold, equalization is triggered.

[0008] Candidate cold logical interval determination steps: Divide logical intervals according to logical addresses, and define the event that causes old physical pages to fail and update the mapping table due to host write or garbage collection as a mapping failure update event. If no mapping failure update event occurs in a certain logical interval within the time window, the logical interval is determined as a candidate cold logical interval.

[0009] Interchangeable object selection step: Select a first candidate cold logic interval mapped to a high wear block and a second candidate cold logic interval mapped to a low wear block, wherein the number of erase / write operations of the high wear block is not less than a second threshold, the number of erase / write operations of the low wear block is less than or equal to a third threshold, and the second threshold is greater than the third threshold;

[0010] Interval mapping swapping steps: Without moving existing valid user data pages, simply update the physical page set identifiers or interval descriptors for the first and second candidate cold logical intervals used for subsequent writing in the mapping table, swap the physical page sets corresponding to the first and second candidate cold logical intervals; and persist the mapping table update records and related block states as logs.

[0011] Furthermore, the mapping table stores a range descriptor for each logical range, and the range descriptor includes a physical page set identifier, a starting physical address, and a range length; the range mapping swapping step completes the swapping of the range descriptors corresponding to the first candidate cold logical range and the second candidate cold logical range by updating the same metadata page, and writes verification information into the metadata page.

[0012] Further, before performing the interval mapping swapping step, swapping lock flags are set for the first candidate cold logical interval and the second candidate cold logical interval; during the validity period of the swapping lock flags, when a host write request pointing to the first candidate cold logical interval or the second candidate cold logical interval is received, the host write request is written to the third physical page set and the corresponding mapping relationship is recorded in the log; when a host read request pointing to the first candidate cold logical interval or the second candidate cold logical interval is received, the corresponding physical address is determined according to the mapping table and the log record for reading; after the swapping is completed, the mapping relationship is written to the mapping table and the swapping lock flags are cleared.

[0013] Further, the candidate cold logic interval determination step sets a first time window and a second time window, and the duration of the second time window is longer than the duration of the first time window; a logic interval that satisfies the condition that no mapping failure update event occurs within the first time window but has occurred within the second time window is determined as the first cold logic interval; a logic interval that satisfies the condition that no mapping failure update event occurs within the second time window is determined as the second cold logic interval; the swap object selection step selects the first candidate cold logic interval from the first cold logic interval and selects the second candidate cold logic interval from the second cold logic interval.

[0014] Furthermore, after setting the swap lock flag, the interval descriptors corresponding to the first candidate cold logical interval and the second candidate cold logical interval are written into the reserved metadata area as a snapshot before the swap; when a power failure recovery or system reset occurs during the validity period of the swap lock flag, the mapping table is rolled back or replayed and updated according to the mapping relationship between the snapshot before the swap and the log records.

[0015] Furthermore, during the period when the swap lock flag is valid, host write requests pointing to the first candidate cold logical interval or the second candidate cold logical interval are written to the third physical page set, and the correspondence between logical addresses and physical addresses is recorded in the log in the order of receipt; after the swap is completed, the correspondence is merged and written to the mapping table according to the log recording order.

[0016] Furthermore, the first time window and the second time window are determined by the global mapping failure update event count, and the second count value is greater than the first count value; the first cold logic interval satisfies that the number of mapping failure update events is zero within the first count value range, and the number of mapping failure update events is non-zero within the second count value range; the second cold logic interval satisfies that the number of mapping failure update events is zero within the second count value range.

[0017] Furthermore, when there are multiple logic intervals that satisfy the first cold logic interval condition, the logic interval with the largest number of erase / write operations in the corresponding high-wear block is selected as the first candidate cold logic interval; when there are multiple logic intervals that satisfy the second cold logic interval condition, the logic interval with the smallest number of erase / write operations in the corresponding low-wear block is selected as the second candidate cold logic interval.

[0018] Furthermore, when the lengths of the first cold logic interval and the second cold logic interval are not the same, the logic interval with the larger interval length is divided into multiple sub-intervals, such that the length of the sub-intervals is the same as that of the logic interval with the smaller interval length, and the first cold logic interval or the second cold logic interval is determined from the sub-intervals according to the determination condition.

[0019] Furthermore, in the mapping table, sub-interval descriptors are generated for each sub-interval and shared flags are set so that sub-intervals with the same shared flags point to a continuous address range of the same physical page set; when determining the first cold logical interval or the second cold logical interval, the sub-intervals with the same shared flags are grouped together and the interval mapping interchange step is performed.

[0020] The beneficial effects of this invention are as follows: By introducing a triggering mechanism based on wear difference indicators, this invention achieves on-demand write-balanced startup, avoiding unnecessary background migration operations when wear differences are small, thereby effectively reducing write amplification and performance jitter. Simultaneously, through a cold logical interval determination mechanism based on time windows and mapping failure update events, logical intervals are distinguished according to update activity levels. Combined with a dual-threshold filtering strategy for high-wear and low-wear blocks, swappable objects with clear wear gradient differences are constructed. This method achieves the exchange of physical page sets only by updating interval descriptors without moving existing valid user data pages. It can achieve wear redistribution while maintaining the physical location of data, significantly reducing data migration overhead and improving the overall lifetime utilization of flash memory media.

[0021] Furthermore, this invention achieves read-write isolation and mapping consistency control during interval mapping swaps by setting swapping lock flags, a third physical page set buffer writing mechanism, and a log sequential recording mechanism, ensuring data correctness in concurrent access scenarios. Through unified metadata page updates, verification information writing, and pre-swap snapshot and log replay mechanisms, the mapping table can be rolled back or replayed to restore it in the event of power failure or abnormal reset, ensuring consistency between the mapping relationship and the block state. Combined with the sub-interval partitioning and shared flag grouping exchange mechanism, alignment swaps can still be achieved even when interval lengths are inconsistent, reducing the number of mapping table updates, thereby improving execution efficiency and system stability while ensuring reliability. Attached Figure Description

[0022] Figure 1 This is a flowchart illustrating the logical judgment process of the solid-state drive write balancing optimization method of the present invention.

[0023] Figure 2 This is a distribution of erase block write times and threshold layering diagram within the statistical range in Embodiment 1 of the present invention.

[0024] Figure 3 This is a schematic diagram of the wear difference index and exponential smoothing trigger determination in Embodiment 1 of the present invention.

[0025] Figure 4 This is a comparison chart of the traditional scheme and the scheme with only mapping interchange in the comparative experiment of Embodiment 1 of the present invention.

[0026] Figure 5 This is a line graph showing the plot of the counting window N to the equivalent time window T and the annotation of N1 and N2 in Embodiment 2 of the present invention.

[0027] Figure 6 This is a graph showing the number of logical interval events and the determination of the first and second cold events under the dual counting window in Embodiment 2 of the present invention.

[0028] Figure 7This is a graph showing the selection of extreme values ​​and the calculation of the difference reduction in the candidate PE values ​​in the cold region in Embodiment 2 of the present invention. Detailed Implementation

[0029] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0030] Combined with appendix Figure 1 This invention relates to a write balancing optimization method for solid-state drives (SSDs), applied to SSDs comprising a controller and flash memory media. The controller manages the data read / write and address translation relationships of the flash memory media, and internally maintains a mapping table from logical addresses to physical pages, as well as erase / write count information for each erase block. The mapping table records the correspondence between logical addresses and physical pages, and the erase / write count information reflects the utilization level of each erase block.

[0031] During operation, the controller periodically acquires the number of erase / write operations for each erase block within a predetermined statistical range. The predetermined statistical range is the set of erase blocks currently participating in data allocation and garbage collection management. The controller determines the maximum and minimum number of erase / write operations within this statistical range and calculates the difference between them as a wear difference index. The wear difference index measures the degree of wear dispersion among erase blocks within the current flash memory medium. When the wear difference index is not less than a first threshold, the controller determines that there is an uneven wear state among the erase blocks and triggers a write balancing process; when the wear difference index is less than the first threshold, no balancing operation is performed.

[0032] After triggering the write load balancing process, the controller divides the logical addresses in the mapping table into multiple logical intervals based on logical address continuity. Each logical interval corresponds to a set of consecutive logical addresses and their mapped physical pages. The controller monitors mapping failure update events for each logical interval. Mapping failure update events include host write operations or garbage collection operations that cause the original physical pages to become invalid and update the mapping table entries. The controller maintains time window counter information for each logical interval to record whether a mapping failure update event occurs within that time window.

[0033] If a logical interval does not experience a mapping failure update event within a time window, it is determined that the logical interval has not been updated in the current time period, and the controller marks this logical interval as a candidate cold logical interval. The candidate cold logical interval serves as the basis for subsequent balancer selection, and is used to redistribute erase block wear by adjusting the mapping relationship without moving existing valid user data pages.

[0034] After determining the candidate cold logic intervals, the controller filters them based on the erase / write count information of each erase block. The controller pre-stores a second threshold and a third threshold, ensuring that the second threshold is greater than the third threshold. The second threshold is used to define the criteria for high-wear blocks, and the third threshold is used to define the criteria for low-wear blocks.

[0035] The controller iterates through the candidate cold logic intervals and queries the erase count of the erase block containing the physical page set corresponding to each candidate cold logic interval. When the erase count of the erase block corresponding to a candidate cold logic interval is not less than a second threshold, the candidate cold logic interval is classified as a candidate interval mapped to a high-wear block. In this type of interval, the controller determines a first candidate cold logic interval according to a preset selection rule. The selection rule can be to prioritize the interval with the larger erase count or to determine it according to the interval identifier order.

[0036] Simultaneously, the controller filters out logical intervals from the candidate cold logical intervals whose corresponding erase block write count is less than or equal to a third threshold, and classifies them as candidate intervals mapped to low-wear blocks. Within this category, the controller determines a second candidate cold logical interval. Through the above steps, the controller obtains a first candidate cold logical interval mapped to high-wear blocks and a second candidate cold logical interval mapped to low-wear blocks, respectively, providing the object basis for subsequent interval mapping and swapping, thereby achieving wear redistribution without moving valid user data pages.

[0037] After determining the first and second candidate cold logic intervals, the controller executes the interval mapping swapping step. This swapping step is performed without moving existing valid user data pages, without changing the physical location of valid user data pages already stored in the flash memory, and without copying or migrating the data content within the physical page set.

[0038] The controller locates the interval descriptors corresponding to the first and second candidate cold logical intervals in the mapping table. Each interval descriptor includes a physical page set identifier and address information related to subsequent write allocations. The controller updates the physical page set identifier in the interval descriptor to change the physical page set allocated for subsequent writes to the first candidate cold logical interval to the original physical page set corresponding to the second candidate cold logical interval, and vice versa, thus completing the physical page set exchange between the two logical intervals.

[0039] After completing the interval descriptor update, the controller writes the mapping table update record to a preset log area. The log record includes the identifier of the swapped logical interval, the identifiers of the physical page sets before and after the swap, and the relevant erase block status information. After the log is written, the controller submits the mapping table update result. Through the persistent writing using the above log method, in the event of a power outage or system anomaly, the consistency of the mapping relationship and block state can be restored based on the log record, ensuring the reliability of the interval mapping swapping process.

[0040] The mapping table is organized by logical intervals as management units. The controller stores a corresponding interval descriptor for each logical interval, which records the mapping relationship between the logical interval and physical storage resources. Each interval descriptor includes at least a physical page set identifier, a starting physical address, and an interval length. The physical page set identifier identifies the set of physical pages currently allocated for subsequent writes within the logical interval; the starting physical address indicates the starting position of the physical page set; and the interval length indicates the range of logical addresses or the corresponding number of physical pages covered by the logical interval.

[0041] To improve the consistency and update efficiency of the interval mapping swap process, the controller stores the interval descriptors of the first and second candidate cold logical intervals in the same metadata page. The metadata page is the smallest write unit used to store the key structure of the mapping table. When executing the interval mapping swap step, the controller constructs the updated interval descriptor content in memory and updates the entire metadata page through a single write operation, thereby completing the swap of the corresponding interval descriptors of the first and second candidate cold logical intervals.

[0042] When writing to the metadata page, the controller simultaneously generates and writes verification information. This verification information is used to verify the integrity of the updated interval descriptor data. During system startup or recovery, the controller reads the metadata page and verifies the verification information to determine whether the interval descriptors are complete and valid, ensuring that the interval mapping swap operation maintains consistency and reliability even in abnormal situations.

[0043] Before executing the interval mapping swap step, the controller first sets swap lock flags for the first candidate cold logical interval and the second candidate cold logical interval. The swap lock flag is used to indicate that the corresponding logical interval is in the mapping swap processing stage. During the validity period of the flag, direct modification of the original interval descriptor of the logical interval is suspended to prevent concurrent access from causing mapping inconsistencies.

[0044] When a host write request is received pointing to either the first or second candidate cold logical range during the swap lock period, the controller does not directly allocate physical pages according to the current range descriptor. Instead, it writes the host write request to a pre-allocated third physical page set. The third physical page set is a set of physical resources used to temporarily host newly written data during the swap. Simultaneously, the controller records the mapping relationship between the logical address corresponding to the host write request and the physical addresses in the third physical page set in the log area to preserve incremental mapping information generated during the swap.

[0045] When a host read request pointing to the first or second candidate cold logical range is received during the period when the swap lock flag is valid, the controller first queries the mapping table to determine whether a corresponding stable mapping relationship exists. At the same time, it queries the log record. If an updated mapping relationship corresponding to the logical address exists in the log, the physical address recorded in the log is used for reading. If no corresponding record exists in the log, the physical address is determined according to the original range descriptor in the mapping table for reading, thereby ensuring the correctness of the read operation during the swap.

[0046] After completing the range descriptor swap and updating the mapping table, the controller merges the mapping relationships between logical addresses and the third physical page set recorded in the log and writes them into the mapping table, making the newly added mapping relationships generated during the swap into formal mapping relationships. Then, the swap lock flags of the first and second candidate cold logical ranges are cleared, allowing the logical ranges to resume normal read / write processing.

[0047] After setting the swap lock flag, the controller reads the interval descriptors corresponding to the first and second candidate cold logical intervals into the internal cache and writes the interval descriptors into the reserved non-volatile metadata area, forming a snapshot before the swap. The snapshot before the swap includes information such as the interval identifier, physical page set identifier, starting physical address, and interval length, used to record the stable mapping state before the swap operation begins. The reserved metadata area is independent of the regular mapping table storage area to ensure that it can be read and recovered independently in abnormal situations.

[0048] During the period when the swap lock flag is valid, if a power outage recovery or system reset occurs, the controller first reads the pre-swap snapshot in the reserved metadata area during startup initialization, and simultaneously reads the mapping relationships recorded in the log area. The controller determines whether the mapping table has completed the range descriptor swap based on the pre-swap snapshot; if the swap is not completed, the controller restores the mapping table to its pre-swap state based on the pre-swap snapshot; if the swap is completed but there are unmerged log mapping relationships, the controller performs a replay update on the mapping table based on the log records to keep the mapping table state consistent with the log records, thereby ensuring the atomicity and consistency of the swap process under abnormal conditions.

[0049] During the period when the swap lock flag is valid, the controller writes host write requests pointing to the first or second candidate cold logical range to the third physical page set, and records the mapping relationship between logical addresses and corresponding physical addresses in the log in the order of receipt. The receipt order is based on the time order in which the host write requests arrive at the controller. After the range descriptor swap is completed, the controller writes the mapping relationship between logical addresses and physical addresses into the mapping table in the order recorded in the log, so that the write mappings generated during the swap are merged into the formal mapping relationship in the original order. Then, the swap lock flag is cleared and the reserved metadata area is released.

[0050] To differentiate logical intervals with varying update activity levels, the candidate cold logical interval determination step sets up a first time window and a second time window. The duration of the second time window is longer than that of the first time window. The controller maintains records of mapping failure update events for each logical interval and separately counts whether mapping failure update events occur within the first and second time windows.

[0051] If a logical interval does not experience a mapping failure update event within the first time window, but does experience one within the second time window, this logical interval is designated as the first candidate cold logical interval. These logical intervals have not been updated recently, but have exhibited update activity over a longer period, representing logical intervals with decreasing update frequency. If a logical interval does not experience a mapping failure update event within the second time window, this logical interval is designated as the second candidate cold logical interval. These logical intervals remain unupdated over a longer period, representing stable cold logical intervals.

[0052] In the swapping object selection step, the controller selects a first cold logic interval from the first candidate cold logic intervals and a second cold logic interval from the second candidate cold logic intervals based on the above determination results. By distinguishing the update characteristics under different time scales, logic intervals with slowing update trends and long-term static logic intervals are classified separately, providing an object basis with time-difference characteristics for subsequent interval mapping swapping, thereby achieving more refined write balance control.

[0053] The first and second time windows are not measured by fixed durations, but are determined by the count of global mapping failure update events. The controller accumulates the count of global mapping failure update events and constructs a sliding counting interval based on the most recent mapping failure update event. The first time window corresponds to a first count value range, and the second time window corresponds to a second count value range, with the second count value being greater than the first count value. The controller counts the number of mapping failure update events occurring within each logical interval in both the first and second count value ranges.

[0054] When a logical interval has zero mapped failure update events within a first count range and a non-zero mapped failure update event count within a second count range, this logical interval is designated as a first cold logical interval. These logical intervals have not been updated recently, but there was updating activity in earlier stages. When a logical interval has zero mapped failure update events within a second count range, this logical interval is designated as a second cold logical interval. These logical intervals remain in an unupdated state for a longer period.

[0055] When multiple logical intervals meet the first cold logical interval condition, the controller queries the erase count of the erase block containing the physical page set corresponding to each logical interval, and selects the logical interval with the highest erase count as the first cold logical interval, so that the physical blocks with higher wear levels participate in the balancing process first. When multiple logical intervals meet the second cold logical interval condition, the controller selects the logical interval with the lowest erase count in the erase block containing the corresponding physical page set as the second cold logical interval, so that the physical blocks with lower wear levels can handle the subsequent write load.

[0056] When the lengths of the first cold logic interval and the second cold logic interval are different, the controller divides the logic interval with the larger interval length into multiple sub-intervals according to a fixed length rule, so that the length of each sub-interval is the same as that of the logic interval with the smaller interval length. Then, in the sub-intervals, the first or second cold logic interval is re-determined according to the aforementioned counting judgment condition to ensure that the lengths of the logic intervals participating in the mapping and interchange are consistent.

[0057] In the mapping table, the controller generates sub-range descriptors for each sub-range and sets the same shared tag for sub-ranges originating from the same original logical range. The shared tag is used to identify sub-ranges that have the same source relationship and that sub-ranges with the same shared tag point to a contiguous address range of the same physical page set. When determining the first or second cold logical range, sub-ranges with the same shared tag are treated as a whole and the range mapping swapping step is performed, thereby completing the mapping adjustment while maintaining the continuity of physical pages and reducing the number of mapping table updates.

[0058] Example 1:

[0059] This embodiment relates to a database log disk during e-commerce promotions. In this scenario, the host has a mixed load of order and payment systems. After the promotion begins, there is a sudden surge in hot writes, while cold data remains stagnant for a long time. During inspection, the controller finds a significant increase in the difference between write and erase operations. Therefore, instead of moving existing valid user data pages, it changes the subsequent write landing point by swapping the range descriptors in the mapping table, thereby smoothing out wear.

[0060] The solid-state drive (SSD) has a capacity of 1TB, an 8-channel controller, a flash page size of 16KB, an erase block size of 4MB, and each block contains 256 pages, with a 7% over-reservation ratio. The controller maintains a logical address to physical page mapping table, divided into logical intervals of 256MB. Each logical interval corresponds to an interval descriptor, with fields including physical page set identifier, starting physical address, and interval length. The statistical range selects the 2048 most recently active erase blocks, and maintains the erase / write count and block status for each erase block.

[0061] The timeline is as follows: T0 is the night before the promotion, with stable log disk writes and a consistent hot / cold disk distribution. T1 is 5 minutes after the promotion starts, with a surge in order writes and payment transaction writes, leading to increased garbage collection frequency. T2 is 30 minutes after the promotion starts, with the controller performing wear checks and discovering that some blocks have continuously increasing write / erase counts while others have consistently low wear. T3 is 31 minutes after the promotion starts, and after the trigger conditions are met, interval mapping swap balancing is performed, with relevant write requests redirected and logged during the swap locking period.

[0062] Table 1 shows the number of erase / write operations for 16 sampled erase blocks within the statistical range, in units of times. The sampling is used to illustrate the calculation process; in actual implementation, the controller calculates the extreme values ​​for all blocks within the statistical range.

[0063] Table 1

[0064]

[0065] Combination Figure 2 The erase / write cycle distribution and threshold stratification shown are illustrated, and the wear difference index is calculated using the following formula:

[0066] ;

[0067] The maximum number of erase / write cycles is 8120, and the minimum number of erase / write cycles is 1380. Therefore, the result of this inspection is D = 8120 - 1380 = 6740. The thresholds are set as follows: first threshold 2000, second threshold 6500, and third threshold 2500, with the second threshold being greater than the third threshold. Because... This triggers equalization. Furthermore, high-wear blocks are defined as blocks with at least 6500 write cycles, and low-wear blocks are defined as blocks with at least 2500 write cycles. Therefore, blocks B01 to B08 belong to the high-wear block set, and blocks B13 to B16 belong to the low-wear block set. Figure 2 The calculation result and interpretation correspond to D=6740 triggering equilibrium, and the high wear block set and low wear block set are divided according to the second threshold and the third threshold, providing a basis for subsequent selection of mapping and swapping objects.

[0068] To avoid frequent triggering due to instantaneous fluctuations, exponential smoothing can be applied to the differential indicators. Figure 3The correlation between the difference index D and the exponential smoothing curve is shown. (Take...) and order ,use:

[0069] ;

[0070] Assuming the smoothing value of the previous period This period ,but . Figure 3 The corresponding exponential smoothing is used to suppress frequent equalization caused by instantaneous fluctuations. In this embodiment, the wear difference still increases significantly after smoothing, indicating that the wear difference is caused by promotional hot writes and is persistent, making the triggering of equalization reasonable. The controller can use D and As the triggering criterion, this embodiment directly triggers the threshold D.

[0071] The candidate cold logical interval determination uses a 30-second time window. A mapping failure update event is defined as an event where host writes or garbage collection cause old physical pages to fail and update the mapping table. The controller maintains a window counter for each logical interval. Taking logical interval LQ17 as an example, its logical address range is from LBA8912896 to LBA9437183, corresponding to 256MB. The number of mapping failure update events within the 30-second window is 0, therefore it is identified as a candidate cold logical interval. For another example, logical interval LQ03 has 0 event counts within the window, but its mapping falls within the low-wear block set, making it also a candidate cold logical interval. Subsequently, the first candidate cold logical interval LQ17, mapped to the high-wear block set, is selected from the candidate cold logical intervals, and the second candidate cold logical interval LQ03, mapped to the low-wear block set, is selected. The conditions are met: the high-wear block erase / write count corresponding to the first candidate cold logical interval is not less than 6500, and the low-wear block erase / write count corresponding to the second candidate cold logical interval is less than or equal to 2500.

[0072] During the swap preparation phase, the controller sets swap lock flags for LQ17 and LQ03 and writes their current range descriptors to the reserved metadata area as a snapshot before the swap. An example snapshot is as follows: LQ17 corresponds to the physical page set identifier SetH17, with a starting physical address of PPA0x1A000000 and a range length of 256MB. LQ03 corresponds to the physical page set identifier SetL03, with a starting physical address of PPA0x03000000 and a range length of 256MB. While the lock flag is active, all host write requests to LQ17 or LQ03 are not directly written to SetH17 or SetL03, but are redirected to the third physical page set SetT99, and logged in the order of receipt to ensure data consistency during the swap and prevent any existing valid user data pages from being moved.

[0073] During the swap execution phase, only the interval descriptors in the mapping table are updated to exchange physical page set identifiers; no user-valid page migration is performed. The controller places the interval descriptors of LQ17 and LQ03 in the same metadata page MP08, completing the swap in a single metadata page update. Specifically, the physical page set identifier of LQ17 is updated to SetL03, and the physical page set identifier of LQ03 is updated to SetH17. Simultaneously, the interval length field remains unchanged, and the starting physical address field is updated to the starting address of the corresponding set. When writing the metadata page, a CRC32 checksum is written to the end of the page for monitoring metadata page integrity after power failure. After completing the metadata page write, the controller persistently writes the mapping table update record and related block status as a log. The log includes a swap start marker, swap object identifier, metadata page number, CRC32 value, and swap completion marker.

[0074] The read / write process during the lockout period is as follows. After a write request is redirected to SetT99, the log records the correspondence between logical addresses and physical addresses in the order they are received. The log fields include timestamp, LBA, new PPA, and target set identifier. When a read request arrives, the controller first looks up the mapping table to obtain the current range descriptor for that logical range, and then looks up the interchange log to determine if there is an update overwriting it. If so, it reads the latest PPA recorded in the log; otherwise, it reads according to the mapping table. Table 2 shows three sample log records.

[0075] Table 2

[0076]

[0077] After the swap is completed, the controller merges the corresponding relationships in SetT99 into the mapping table according to the log record order and writes them back to the corresponding logical page mappings. It then writes back the batch of mapping updates that need to be fixed to the range descriptor range, and then clears the swap lock flags of LQ17 and LQ03. At this time, subsequent writes will fall into the swapped physical page set according to the new range descriptor. The write pressure that was originally located in the high wear block set is redirected to the low wear set, and vice versa, thereby gradually reducing the wear difference in subsequent write processes.

[0078] Power-down recovery has two branches. If the system loses power after writing the swap start flag and snapshot, but before writing the metadata page MP08 or the swap completion flag, the recovery process rolls back the mapping table range descriptors to the pre-swap state based on the pre-swap snapshot, and replays the write mappings in SetT99 to the rolled-back mapping table based on the logs, ensuring no writes are lost. If the system loses power after writing to the metadata page MP08 and passing the CRC32 check, and the swap completion flag has been persisted, the recovery process directly loads the mapping table based on the post-swap range descriptors, and merges and writes back the LBA-PPA correspondences during the lock period in sequence based on the logs. After replaying, the SetT99 space is released. For example, if the reset point occurs when the metadata page is written but the log merging is not complete, the recovery process will select the replay branch based on the swap completion flag to avoid inconsistencies where half swaps are performed and half are not.

[0079] The comparative test was conducted under the same promotional playback load for 24 hours. The traditional load balancing scheme moves active pages, transferring 256MB of cold data from a low-wear block to a high-wear block to free up space, resulting in additional user page copying and writing. This embodiment only performs mapping swapping and metadata writing. Results show that after 24 hours, the wear difference index decreased from 6740 to 4200, while the traditional scheme decreased to 3900, but at a higher cost. Write amplification increased from 1.45 to 1.78 in the traditional scheme, while it remained at 1.48 in this embodiment. The P99 write latency was 19.5ms in the traditional scheme and 7.2ms in this embodiment. Figure 4 The above three indicators are normalized and displayed based on the traditional scheme. The bar and line graphs together show the improvement ratio of this embodiment relative to the traditional scheme and the original numerical labels, so as to facilitate the summary and comparison on the same scale.

[0080] The percentage of log overhead during the locking period is calculated as follows:

[0081] ;

[0082] Set the number of log entries in the locked window. Size of each log entry B, Host write volume within the window If the log write volume is GB, then the log write volume is 1152000B, which is approximately 1.099MB. . Figure 4Compared to the traditional solution, a normalized comparison of wear variance, write amplification, and P99 write latency was performed. This embodiment significantly outperforms the traditional solution in terms of write amplification and P99 write latency. While the wear variance is slightly higher than the traditional solution, it is still significantly lower than at trigger time. This demonstrates a trade-off between lower write amplification and lower tail latency for a slightly larger wear variance but lower cost. Regarding metadata overhead, this embodiment writes approximately 1.099MB of metadata (16KB) plus log data, while the traditional solution introduces approximately 256MB of effective page migration writing in addition to metadata.

[0083] In the alternative implementation, the physical page set identifier can be replaced by the set number in the interval descriptor with a continuous physical address range number to reduce the length of metadata fields while maintaining the interchange semantics. The time window can be replaced by a fixed 30-second window that is adaptive based on the global event rate, shortening the window to improve response speed during peak promotional periods and lengthening the window to reduce jitter during low-load periods. Logs can employ segmented verification and dual-write pointers to improve power-down consistency, while still maintaining the principle of recording LBAs to PPAs in the order of reception during the lockout period and sequentially merging and writing them back after the interchange.

[0084] Example 2:

[0085] This embodiment relates to an in-vehicle video recording loop overwrite storage system. The vehicle's front and rear cameras continuously write segmented video files, with intensive writing during daytime driving and reduced writing during nighttime parking. At the same time, the system generates index files daily and performs summary cleanup weekly. This results in some logical intervals not experiencing mapping failure update events in a short period of time, but experiencing over-updates over a longer period of time, thus forming the typical behavior of short-window cold but long-window not cold.

[0086] The solid-state drive (SSD) has a capacity of 512GB, a 4-channel controller, a page size of 16KB, an erase block size of 4MB, and an over-reservation ratio of 10%. The controller maintains a logical address-to-physical page mapping table and erase / write count information. The mapping table is divided into logical intervals of 128MB. To handle inconsistent page lengths, the sub-interval size is set to 32MB. A mapping failure update event is defined as an event where the host writes a new page or garbage collection causes an old page to become invalid and update the mapping table. The shared tag generation rule maps object IDs of the same video segment file to the same shared tag, and several sub-interval descriptors corresponding to the same shared tag point to a continuous physical address range of the same physical page set.

[0087] The timeline is as follows: T0 is when the vehicle is powered on and the recording task is loaded; the mapping table and write / erase counts enter the working state. T1 is the morning peak driving phase, with intensive cyclic overwrite writes and active garbage collection. T2 is the parking phase, entering a stable period; some indexes and weekly summary areas do not update for a short time, but updates are still triggered by periodic rotation over a longer period. T3 is when the controller detects write / erase differences within the statistical range during inspection, triggering the equalization process. Subsequently, it determines cold intervals based on dual-window counting and performs grouped interval mapping swaps to change the subsequent write landing points without moving existing valid user data pages.

[0088] The event counting window is determined by updating the event count after a global mapping failure. The controller maintains global event sequence numbers and uses the most recent N1 events as the first counting window and the most recent N2 events as the second counting window, ensuring that N2 is greater than N1. In this embodiment, N1 is set to 2000 and N2 to 10000, and the event count values ​​cnt1 and cnt2 within these two counting ranges are maintained in each logical interval. For ease of understanding, the counting window can be converted into an average time window, assuming the peak global event rate is... events / s, then:

[0089] ;

[0090] ;

[0091] Figure 5 The diagram illustrates the piecewise linear mapping from the counting window N to the equivalent time window T, and labels T1 and T2 corresponding to N1 and N2. The calculation results are as follows: and This reveals the longer time range corresponding to the second window, which is used to identify colder intervals within the second counting window where there are no update events, thus satisfying the requirement of a longer second window.

[0092] Table 3 presents the statistics of the number of mapping failure update events for 10 logical intervals within two counting windows, and labels the first cold logical interval and the second cold logical interval accordingly. The first cold logical interval satisfies that cnt1 is 0 and cnt2 is non-zero, while the second cold logical interval satisfies that cnt2 is 0.

[0093] Table 3

[0094]

[0095] Figure 6 This section displays a comparison of grouped bar charts for each logical interval under cnt1 and cnt2, along with the labeling of cold intervals. The first cold condition in the calculation results is... and The first cold interval number is 4, and the second cold condition is c. The corresponding number of the second cold interval is 4. The first cold interval is characterized by no updates in the short window but updates in the long window, which conforms to the periodic rotation behavior caused by daily indexing and weekly summarization. The second cold interval is characterized by no mapping failure update events within the second counting window and is suitable as an interchangeable object for low-wear bearing sets.

[0096] When multiple candidates satisfy the first cold condition exist, the logical interval with the largest number of erase blocks is selected as the first cold logical interval. When multiple candidates satisfy the second cold condition exist, the logical interval with the smallest number of erase blocks is selected as the second cold logical interval. Table 4 shows the number of erase blocks (PE) mapped to the candidate logical intervals in Table 3, and extreme value selection is performed accordingly.

[0097] Table 4

[0098]

[0099] As shown in Table 4, the largest PE among the first cold candidates is 7220, corresponding to LQ04. Therefore, LQ04 is determined to be the first cold logic interval. The smallest PE among the second cold candidates is 1250, corresponding to LQ10. Therefore, LQ10 is determined to be the second cold logic interval. Figure 7 The comparison of PE values ​​between the first and second coldest candidates and the extreme value selection annotation are shown. The calculation results show that the first coldest candidate, taking the maximum PE value, yields LQ04 of 7220, while the second coldest candidate, taking the minimum PE value, yields LQ10 of 1250. The difference between the two is 7220 - 1250 = 5970. Selecting swap objects according to the extreme value rule can direct more subsequent writes to the low-wear set, thereby reducing the rate at which high-wear blocks continue to climb and promoting the convergence of wear differences. The controller then checks whether the interval lengths of the two are consistent and prepares to perform interval mapping swapping, so that subsequent writes are directed from the high-wear block set to the low-wear block set, achieving write balance optimization.

[0100] When the lengths of the first cold logical interval and the second cold logical interval are different, the logical interval with the larger interval length is divided into sub-intervals. This embodiment provides an example of inconsistent lengths: interval A is 128MB, corresponding to the video index and weekly summary area, and interval B is 32MB, corresponding to a certain fixed video segment directory area. Interval A is divided into four 32MB sub-intervals A1 to A4, making the length of each sub-interval the same as that of interval B. From A1 to A4, the sub-intervals that satisfy the first or second cold criteria are determined according to the dual-window counting conditions in Table 3 as the interchangeable objects.

[0101] The controller generates sub-interval descriptors for each sub-interval in the mapping table and sets a shared flag, ensuring that sub-intervals with the same shared flag point to a contiguous address range within the same physical page set. An example of the sub-interval descriptor fields is shown below, including the starting physical address, interval length, physical page set identifier, and shared flag. The shared flag is generated using an object ID hash truncated to 16 bits. Since the same video segment file and its index metadata use the same object ID, they can obtain the same shared flag. Because sub-interval descriptors with the same shared flag point to a contiguous address range within the same physical page set, the controller can treat them as the same group for consistent swapping, avoiding the splitting of data from the same object into multiple non-contiguous sets due to swapping only a portion of the sub-intervals.

[0102] This embodiment provides two examples of shared tag groups. Shared tag G21 corresponds to the two sub-intervals A1 and A2, both pointing to the physical page set SetX, with their starting physical addresses being consecutive and covering a range of 64MB. Shared tag G37 corresponds to the two sub-intervals A3 and A4, both pointing to the physical page set SetY, with their starting physical addresses being consecutive and covering a range of 64MB. If the second cold interval B maps to the low-wear physical page set SetZ, when the controller determines the swapping object, it swaps either group G21 as a whole with B, or group G37 as a whole with B, thereby ensuring that sub-intervals with the same shared tag maintain consistency during the swapping process.

[0103] The group swapping process follows the basic process of this embodiment and combines it with a sub-interval grouping strategy. The controller first calculates the erase / write difference index within the statistical range and confirms that it has reached the trigger threshold. Then, it determines the candidate cold intervals according to Table 3 and makes extreme value selection according to Table 4. Subsequently, it divides the longer intervals into sub-intervals and groups them according to the shared tag. When performing the swap, the physical page set identifier or interval descriptor in the interval descriptor is swapped in groups, so that the first cold group is switched from the high wear physical page set to the continuous address range corresponding to the low wear set, and at the same time, the second cold interval or its corresponding group is switched to the high wear set. The swapping process does not move existing valid user data pages, but only updates the mapping metadata and persists the start and completion status of the swap and the status of related blocks in the log.

[0104] To avoid inconsistencies caused by only partially completing the group swap process, the controller employs a batch update strategy within the same metadata page for the same shared tag group. This involves simultaneously swapping the physical page set identifiers of all sub-range descriptors within the group during a single metadata page write, and writing verification information to the metadata page for recovery monitoring. When a shared tag group containing four sub-ranges is detected, but only two sub-ranges are successfully updated, the recovery process, based on metadata verification and persistent logs, chooses to roll back to the snapshot before the swap or continue replaying to complete the update of the remaining sub-ranges, thereby ensuring the final state of the sub-ranges within the same group is consistent.

[0105] The effectiveness evaluation uses the change in wear difference before and after the swap and the pressure transfer amount of the high-wear block as indicators. Before the swap, the write / erase cycles of the high-wear block corresponding to the first cold object were 7220, and the write / erase cycles of the low-wear block corresponding to the second cold object were 1250, with a difference of 5970. After the swap, subsequent writes will preferentially fall into the low-wear set. Assuming that the write / erase increment of the high-wear block decreases to 60% of its original value in subsequent operating cycles, the reduction in the difference can be approximated as:

[0106] ;

[0107] This demonstrates that simply changing the subsequent write endpoint by mapping swaps can significantly reduce the rate at which high-wear blocks continue to climb, thereby reducing wear differences and improving lifespan consistency.

[0108] In an alternative implementation, the first and second counting windows can be adaptively adjusted under different vehicle operating conditions. For example, N1 and N2 can be increased to reduce jitter when the event rate increases, and decreased to speed up response when the rate decreases. The shared tag can be replaced by a combination of object ID and directory number plus date number to fit the storage organization of vehicle video recordings divided by day. The sub-interval size can be replaced by 16MB to improve the granularity of swapping, while still maintaining the principle of swapping sub-intervals with the same shared tag in groups to ensure consistency and that the mapping relationship of continuous address ranges is not disrupted.

Claims

1. A solid-state drive (SSD) write balancing optimization method, applied to an SSD containing a controller and flash memory media, wherein the controller maintains a logical address to physical page mapping table and erase / write count information, characterized in that... include: Wear difference determination steps: Calculate the difference between the maximum and minimum number of erase / write times for each erase block within a predetermined statistical range as the wear difference index. When the wear difference index is not less than the first threshold, equalization is triggered. Candidate cold logical interval determination steps: Divide logical intervals according to logical addresses, and define the event that causes old physical pages to fail and update the mapping table due to host write or garbage collection as a mapping failure update event. If no mapping failure update event occurs in a certain logical interval within the time window, the logical interval is determined as a candidate cold logical interval. Interchangeable object selection step: Select a first candidate cold logic interval mapped to a high wear block and a second candidate cold logic interval mapped to a low wear block, wherein the number of erase / write operations of the high wear block is not less than a second threshold, the number of erase / write operations of the low wear block is less than or equal to a third threshold, and the second threshold is greater than the third threshold; Interval mapping swapping steps: Without moving existing valid user data pages, simply update the physical page set identifiers or interval descriptors for the first and second candidate cold logical intervals used for subsequent writing in the mapping table, swap the physical page sets corresponding to the first and second candidate cold logical intervals; and persist the mapping table update records and related block states as logs.

2. The solid-state drive write balancing optimization method according to claim 1, characterized in that, The mapping table stores a range descriptor for each logical range. The range descriptor includes a physical page set identifier, a starting physical address, and a range length. The range mapping swapping step completes the swapping of the range descriptors corresponding to the first candidate cold logical range and the second candidate cold logical range by updating the same metadata page, and writes verification information into the metadata page.

3. The solid-state drive write balancing optimization method according to claim 2, characterized in that, Before performing the interval mapping swapping step, swapping lock flags are set for the first candidate cold logical interval and the second candidate cold logical interval; during the validity period of the swapping lock flags, when a host write request pointing to the first candidate cold logical interval or the second candidate cold logical interval is received, the host write request is written to the third physical page set and the corresponding mapping relationship is recorded in the log; when a host read request pointing to the first candidate cold logical interval or the second candidate cold logical interval is received, the corresponding physical address is determined according to the mapping table and the log record for reading; after the swapping is completed, the mapping relationship is written to the mapping table and the swapping lock flags are cleared.

4. The solid-state drive write balancing optimization method according to claim 1, characterized in that, The candidate cold logic interval determination step sets a first time window and a second time window, and the duration of the second time window is longer than that of the first time window; a logic interval that does not have the mapping failure update event in the first time window but has had the mapping failure update event in the second time window is determined as the first cold logic interval; a logic interval that does not have the mapping failure update event in the second time window is determined as the second cold logic interval. The interchangeable object selection step selects the first candidate cold logic interval from the first cold logic interval and the second candidate cold logic interval from the second cold logic interval.

5. The solid-state drive write balancing optimization method according to claim 3, characterized in that, After setting the swap lock flag, the interval descriptors corresponding to the first candidate cold logical interval and the second candidate cold logical interval are written into the reserved metadata area as a snapshot before the swap; when a power failure recovery or system reset occurs during the validity period of the swap lock flag, the mapping table is rolled back or replayed according to the mapping relationship between the snapshot before the swap and the log records.

6. The solid-state drive write balancing optimization method according to claim 3, characterized in that, During the period when the swap lock flag is valid, host write requests pointing to the first candidate cold logical interval or the second candidate cold logical interval are written to the third physical page set, and the correspondence between logical addresses and physical addresses is recorded in the log in the order of receipt; after the swap is completed, the correspondence is merged and written to the mapping table according to the log recording order.

7. The solid-state drive write balancing optimization method according to claim 4, characterized in that, The first time window and the second time window are determined by the global mapping failure update event count, and the second count value is greater than the first count value; the first cold logic interval satisfies that the number of mapping failure update events is zero within the range of the first count value, and the number of mapping failure update events is non-zero within the range of the second count value. The second cold logic interval satisfies the condition that the number of mapping failure update events is zero within the range of the second count value.

8. The solid-state drive write balancing optimization method according to claim 4, characterized in that, When there are multiple logic intervals that satisfy the first cold logic interval condition, the logic interval with the largest number of erase / write operations in the corresponding high-wear block is selected as the first candidate cold logic interval; when there are multiple logic intervals that satisfy the second cold logic interval condition, the logic interval with the smallest number of erase / write operations in the corresponding low-wear block is selected as the second candidate cold logic interval.

9. The solid-state drive write balancing optimization method according to claim 4, characterized in that, When the lengths of the first cold logic interval and the second cold logic interval are not the same, the logic interval with the larger interval length is divided into multiple sub-intervals, such that the length of the sub-intervals is the same as that of the logic interval with the smaller interval length, and the first cold logic interval or the second cold logic interval is determined from the sub-intervals according to the judgment conditions.

10. The solid-state drive write balancing optimization method according to claim 9, characterized in that, In the mapping table, sub-interval descriptors are generated for each sub-interval and shared flags are set so that sub-intervals with the same shared flags point to a continuous address range of the same physical page set; when determining the first cold logical interval or the second cold logical interval, sub-intervals with the same shared flags are grouped together and the interval mapping swapping step is performed.