A dynamic wear leveling method and system for flash memory
By initializing and updating the technical table of erasing and writing times of storage units in real time, identifying and handling abnormal storage units, and dynamically adjusting the data migration and block mapping of flash memory, the problem of uneven erasing and writing times of storage units in flash memory is solved, and the equipment service life is extended. service life and ensure system stability.
Patent Information
- Application Number
- CN202410943476.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-15
AI Technical Summary
The storage cells of flash memory have an uneven number of erasing and writing due to wear and tear, making it difficult to extend the overall service life.
By initializing the erasure and write count technical table of the storage unit, real-time monitoring and updating of the erasure and write count, applying the least erase and write priority strategy to identify abnormal storage units, building a data migration plan, dynamically allocating spare blocks, and adjusting block mapping tables and metadata to ensure health. Parameters are within preset ranges.
It achieves the balance of the number of erase and write times of the storage unit, extends the service life of the flash memory, prevents failure caused by overuse of the unit, and ensures stable operation of the system and data integrity.
Smart Images

Figure CN118538275B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of chip data processing, and in particular to a dynamic wear leveling method and system for a flash memory. Background Art
[0002] Flash memory is a non-volatile memory that is widely used in various electronic devices, such as solid-state drives (SSDs), USB flash drives, mobile phones and digital cameras. Since the storage cells of flash memory have wear life limitations, it is impossible to balance the number of erase and write times of each storage cell, making it difficult to extend the overall service life of the flash memory. Summary of the invention
[0003] The present invention aims to solve the problem of how to effectively balance the number of erase and write times of each storage unit and extend the overall service life of a flash memory, and provides a dynamic wear leveling method and system for a flash memory.
[0004] The present invention adopts the following technical means to solve the technical problem:
[0005] The present invention provides a dynamic wear leveling method for a flash memory, comprising:
[0006] Initialize a preset erasure and writing times technical table of the storage unit based on a preset monitoring script of the storage unit, and use the preset erasure and writing times technical table to record the erasure and writing times of the storage unit;
[0007] Determine whether the number of erase and write times can be updated in real time;
[0008] If it is possible, then detect the operation data of the memory, update the erasure times of the memory unit according to the operation data, apply a preset minimum erasure priority strategy to identify the abnormal memory unit with a difference in the erasure times, build a data migration plan for the memory according to the memory unit and the abnormal memory unit, migrate the pre-stored data from the abnormal memory unit to the memory unit through the data migration plan, and monitor the health parameters of the memory unit and the abnormal memory unit in real time, wherein the operation data specifically includes write operation and erase operation, and the health parameters specifically include the number of bad blocks, read and write delay, and refresh cycle;
[0009] Determining whether the health parameter is within a preset parameter range;
[0010] If not, a pre-built prediction model is applied to predict the storage unit and the abnormal storage unit, and the failed unit is identified from the memory based on the prediction result, the failed unit is marked on the memory, and a preset spare block is dynamically allocated from the memory according to the failed unit, and the failed unit is replaced by the spare block, and the block mapping table of the memory is adjusted, and the logical address of the block mapping table is remapped to the spare block, and the metadata of the memory is updated according to the logical address, and the metadata is pointed from the failed unit to the corresponding spare block.
[0011] Furthermore, before the step of applying the preset minimum erase priority strategy to identify the abnormal storage unit with different erase times, the method further includes:
[0012] Performing an encoding operation on a pre-input data block to generate at least one data check bit, combining the data check bit with the data block to form an encoded data block, and writing the encoded data block into a storage medium;
[0013] Determining whether the storage medium is completely written;
[0014] If so, decode the encoded data block, calculate the data check bit and compare it with the preset storage check bit, identify the error attribute in the encoded data block, apply the preset Hamming code to locate the specific error bit of the encoded data block according to the comparison result, use the storage check bit to correct the encoded data block, and restore the original data of the encoded data block, wherein the error attribute specifically includes the error position and the error type.
[0015] Further, the step of constructing a data migration plan for the memory according to the storage unit and the abnormal storage unit includes:
[0016] Identify pre-selected balancing target units in the memory, match the balancing target units one by one as migration objects of the abnormal storage unit, and divide the priority queues of data migration according to the health parameters of the abnormal storage unit;
[0017] Determining whether the priority queue matches the least-erase-first strategy;
[0018] If so, the migration task information of the abnormal storage unit in the memory is established, and the data migration plan of each abnormal storage unit is constructed according to the migration task information, wherein the migration task information specifically includes a migration path, resource allocation and backup content.
[0019] Furthermore, the step of determining whether the number of erasures and writes can be updated in real time further includes:
[0020] Based on the preset cache size of the memory, an array structure is applied to store the erasure times, erasure operation events are collected in real time, the erasure times are updated to the preset cache, and the erasure times of the storage unit are maintained in the cache;
[0021] Determining whether the number of erasures and writes reaches a preset threshold;
[0022] If so, the preset batch update mechanism is triggered, the erase and write counts in the cache are batch-written to the preset database of the memory, and the erase and write counts in the cache are recorded in the preset log file of the memory by appending writes, and the erase and write consistency between the database and the log file is regularly verified.
[0023] Furthermore, the step of determining whether the health parameter is within a preset parameter range further includes:
[0024] Identify the current operating environment of the memory, and obtain a preset parameter level of the memory based on the current operating environment, wherein the parameter level specifically includes low level, medium level and high level;
[0025] Determining whether the parameter level meets the current operating environment;
[0026] If not, activate the pre-built rule engine in the memory, input the health parameters into the rule engine for rule matching, generate rule conditions that meet the parameter level, and execute the rule conditions according to the current operating environment and the parameter level, wherein the rule conditions specifically include security scans, data snapshots, and aggregated logs.
[0027] Furthermore, the step of applying the erasure and writing number technical table to record the erasure and writing number of the storage unit includes:
[0028] Based on the update cycle preset in the erasable number of technology table, generate a timestamp corresponding to the current update, synchronize the timestamp to the erasable number of technology table, and retain at least one timestamp within a preset period of time from the erasable number of technology table;
[0029] Determine whether the timestamp matches the number of erase / write times of the memory updated at that time;
[0030] If so, a preset erase / write operation event of the memory is triggered, and the corresponding storage unit record in the erase / write times technical table is distinguished according to the response duration of the erase / write operation event.
[0031] The present invention also provides a dynamic wear leveling system for a flash memory, comprising:
[0032] A recording module, used for initializing a preset erasure and writing times technical table of the storage unit based on a preset monitoring script of the storage unit, and using the preset erasure and writing times technical table to record the erasure and writing times of the storage unit;
[0033] A judging module, used for judging whether the erasing and writing times can be updated in real time;
[0034] An execution module, for detecting operation data of the memory, if possible, updating the erasure times of the memory unit according to the operation data, identifying abnormal memory units with different erasure times by applying a preset minimum erasure priority strategy, building a data migration plan for the memory according to the memory unit and the abnormal memory unit, migrating pre-stored data from the abnormal memory unit to the memory unit through the data migration plan, and monitoring health parameters of the memory unit and the abnormal memory unit in real time, wherein the operation data specifically includes write operations and erase operations, and the health parameters specifically include the number of bad blocks, read and write delays, and refresh cycles;
[0035] A second judgment module is used to judge whether the health parameter is within a preset parameter range;
[0036] A second execution module is used for, if not, applying a pre-built prediction model to predict the storage unit and the abnormal storage unit, identifying the failed unit from the memory based on the prediction result, marking the failed unit on the memory, dynamically allocating a preset spare block from the memory according to the failed unit, replacing the failed unit with the spare block, adjusting the block mapping table of the memory, remapping the logical address of the block mapping table to the spare block, updating the metadata of the memory according to the logical address, and pointing the metadata from the failed unit to the corresponding spare block.
[0037] Furthermore, it also includes:
[0038] A generating module, configured to perform an encoding operation on a pre-input data block, generate at least one data check bit, combine the data check bit with the data block to form an encoded data block, and write the encoded data block into a storage medium;
[0039] A third judgment module is used to judge whether the storage medium is completely written;
[0040] The third execution module is used to decode the encoded data block, calculate the data check bit and compare it with the preset storage check bit, identify the error attribute in the encoded data block, apply the preset Hamming code to locate the specific error bit of the encoded data block according to the comparison result, use the storage check bit to correct the encoded data block, and restore the original data of the encoded data block, wherein the error attribute specifically includes the error position and the error type.
[0041] Furthermore, the execution module includes:
[0042] an identification submodule, configured to identify pre-selected balancing target units in the memory, match the balancing target units one by one as migration objects of the abnormal storage units, and divide the priority queues of data migration according to the health parameters of the abnormal storage units;
[0043] A judgment submodule, used for judging whether the priority queue matches the least-erase-first strategy;
[0044] The execution submodule is used to establish the migration task information of the abnormal storage unit in the memory, and construct the data migration plan of each abnormal storage unit according to the migration task information, wherein the migration task information specifically includes the migration path, resource allocation and backup content.
[0045] The present invention provides a dynamic wear leveling method and system for a flash memory, which has the following beneficial effects:
[0046] The present invention can comprehensively monitor the erase and write operations of storage units by initializing a technical table of erase and write times of storage units and using the technical table to record the erase and write times of each storage unit. The least erase and write priority strategy helps to identify abnormal storage units with large differences in erase and write times, thereby achieving erase and write balance and preventing some units from failing prematurely due to excessive use. At the same time, it allows real-time detection of the operating data of the storage and updating of the erase and write times, and real-time monitoring of the health parameters of storage units and abnormal storage units, including the number of bad blocks, read and write delays, and refresh cycles. In this way, potential problems can be discovered in time and dynamic adjustments can be made to ensure stable operation of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A schematic diagram of a flow chart of an embodiment of a dynamic wear leveling method for a flash memory device of the present invention;
[0048] Figure 2 The structure block diagram of an embodiment of the dynamic wear leveling system of the flash memory of the present invention. DETAILED DESCRIPTION
[0049] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. The implementation of the objectives, functional features and advantages of the present invention will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] Reference Figure 1 , a dynamic wear leveling method for a flash memory in an embodiment of the present invention, comprising:
[0052] S1: based on a monitoring script preset in the memory, initializing a preset erasure and writing times technical table for the storage unit, and using the erasure and writing times technical table to record the erasure and writing times of the storage unit;
[0053] S2: Determine whether the number of erase and write times can be updated in real time;
[0054] S3: If it is possible, then detect the operation data of the memory, update the erasure times of the memory unit according to the operation data, apply the preset minimum erasure priority strategy to identify the abnormal memory unit with different erasure times, build a data migration plan for the memory according to the memory unit and the abnormal memory unit, migrate the pre-stored data from the abnormal memory unit to the memory unit through the data migration plan, and monitor the health parameters of the memory unit and the abnormal memory unit in real time, wherein the operation data specifically includes write operation and erase operation, and the health parameters specifically include the number of bad blocks, read and write delay and refresh cycle;
[0055] S4: Determine whether the health parameter is within a preset parameter range;
[0056] S5: If not, apply a pre-built prediction model to predict the storage unit and the abnormal storage unit, identify the failed unit from the memory based on the prediction result, mark the failed unit on the memory, dynamically allocate a preset spare block from the memory according to the failed unit, replace the failed unit with the spare block, adjust the block mapping table of the memory, remap the logical address of the block mapping table to the spare block, update the metadata of the memory according to the logical address, and point the metadata from the failed unit to the corresponding spare block.
[0057] In this embodiment, the system initializes the preset erase and write count technical table of the storage unit based on the monitoring script preset in the flash memory, and uses the erase and write count technical table to record the erase and write count of the storage unit. Then the system determines whether the erase and write count can be updated in real time to execute the corresponding steps. For example, when the system determines that the erase and write count of the storage unit cannot be updated in real time, the system will believe that the storage unit may be physically damaged or close to the end of its life, resulting in unstable erase and write operations. The system will check the system load and configure the load distribution strategy of the erase and write count update task in the load balancer to optimize the resource allocation of key tasks, ensure that high-priority tasks can be executed in time, and perform health checks on the storage unit to evaluate its Physical status, check and analyze system logs, locate the cause of storage failure, and review the current data consistency plan, implement distributed transactions or consistency protocols, ensure the reliability of data update operations, and introduce conflict detection mechanisms to handle concurrent conflicts; for example, when the system determines that the number of erase and write times of a storage unit can be updated in real time, the system will consider that the storage unit can be used normally, and the system will detect the operation data of the storage unit, which specifically includes write operations and erase operations. The number of erase and write times of the storage unit is updated according to these operation data, and the pre-set minimum erase and write priority strategy is applied to identify abnormal storage units with different erase and write times, and a data migration plan for the storage unit is constructed based on the storage unit and the abnormal storage unit. The pre-stored data is migrated from the abnormal storage unit to the storage unit through the data migration plan, and the health parameters of the storage unit and the abnormal storage unit are monitored in real time. The health parameters include the number of bad blocks, read and write delays, and refresh cycles. The system quickly captures each write and erase operation, updates the erase count in real time, and ensures that the usage of each storage unit is reflected in the technical table in a timely manner. At the same time, the system identifies abnormal storage units with large differences in erase counts through strategies to optimize the use of storage units and avoid excessive use of certain units. A data migration plan is built to migrate data from abnormal units to healthy units to protect data integrity, avoid data loss caused by unit failure, and discover storage unit anomalies in advance for prevention. Maintenance; the system then determines whether the health parameters of the storage unit and the abnormal storage unit are within the preset parameter range to execute the corresponding steps; for example, when the system determines that the health parameters of the storage unit and the abnormal storage unit are within the preset parameter range, the system will consider that the operating status and performance of these units are normal and in a healthy state, and no immediate repair or replacement operation is required. The system will continue to monitor the health parameters of the storage unit and the abnormal storage unit in real time to timely discover and handle new problems, and regularly back up data to ensure that data can be restored in the event of an unexpected failure, and record all operation and monitoring data in the database for long-term analysis and problem tracking;For example, when the system determines that the health parameters of the storage unit and the abnormal storage unit are not within the preset parameter range, the system will consider that the operating status and performance of these units are abnormal. The system will apply the pre-built prediction model to predict the storage unit and the abnormal storage unit, identify the failed unit from the memory based on the prediction results, mark these failed units on the memory, dynamically allocate pre-set spare blocks from the memory according to each failed unit, replace these failed units with these spare blocks, adjust the block mapping table of the memory, remap the logical address of the block mapping table to the spare block, update the metadata of the memory according to the logical address, and point the metadata from the failed unit to the corresponding spare block; the system identifies the failed unit in advance through the prediction model, marks and processes it to intervene in advance, avoid data loss or system crash caused by unit failure, and dynamically adjust the spare block allocation according to the actual situation to improve the system adaptability, remap the logical address, maintain the consistency of the system data structure, ensure the stable operation of the system, update the metadata to ensure that it points to the correct storage location, and ensure the overall reliability of the system and the accuracy of data access. ;
[0058] It should be noted that a specific example of applying the pre-built prediction model to predict the storage unit and the abnormal storage unit is as follows:
[0059] Assume that there is a flash storage system that contains several storage units. By monitoring the health parameters of these units in real time, the following data is collected:
[0060] After collecting the above data, the system cleans and normalizes it. First, features are extracted from the data, including the growth rate of erase and write times, the change trend of read and write latency, the change rate of the number of bad blocks, and the acceleration of the error rate. A random forest model is trained using historical data to predict the failure probability of storage units. Then, through cross-validation and parameter optimization, a model with good performance is finally obtained. The real-time health parameters are input into the model, and the model predicts the following results:
[0061]
[0062] Based on the prediction results, the system identifies that unit 4 has a high probability of failure, and takes measures including (marking unit 4 as a high-risk unit), (allocating a new spare block from the spare block pool to replace unit 4), (remapping the logical address of unit 4 to the spare block), and (updating metadata to ensure that the metadata points to the new spare block to maintain data consistency);
[0063] In summary, through the prediction model, the system can identify potential failure units in advance, perform preventive maintenance, reduce sudden failures, dynamically allocate spare blocks, improve system resource utilization, avoid resource waste due to unit failure, adjust block mapping tables and update metadata in real time, ensure the correctness of data access and the stability of system operation, and extend the overall service life of the storage unit through advance processing and optimization measures.
[0064] In this embodiment, before applying the preset minimum erase priority strategy to identify the abnormal storage unit with different erase times S3, it also includes:
[0065] S301: Performing an encoding operation on a pre-input data block to generate at least one data check bit, combining the data check bit with the data block to form an encoded data block, and writing the encoded data block into a storage medium;
[0066] S302: Determine whether the storage medium is completely written;
[0067] S303: If yes, decode the coded data block, calculate the data check bit and compare it with the preset storage check bit, identify the error attribute in the coded data block, apply the preset Hamming code to locate the specific error bit of the coded data block according to the comparison result, use the storage check bit to correct the coded data block, and restore the original data of the coded data block, wherein the error attribute specifically includes the error position and the error type.
[0068] In this embodiment, the system performs an encoding operation on a pre-input data block, generates at least one data check bit, and combines the data check bit with the data block to form a coded data block, writes the coded data block into a storage medium, and then the system determines whether the storage medium is completely written to execute the corresponding steps; for example, when the system determines that the storage medium cannot be completely written to the coded data block, the system will consider that the coded data block itself may be damaged, resulting in the failure of the write operation to be completed smoothly, and the system will wait for a while and then re-execute the write operation to observe whether it is successful. At the same time, the storage unit that cannot be written is marked as a faulty unit, and the unit is isolated from normal read and write operations to prevent further write attempts, and a healthy spare block is selected from the spare block pool to remap the logical address to the new spare block; for example, when the system determines that the storage medium can be completely written to the coded data block, the system will consider that the coded data block itself is damaged, resulting in the failure of the write operation to be completed smoothly, and the system will wait for a while and then re-execute the write operation to observe whether it is successful. At the same time, the system will mark the storage unit that cannot be written as a faulty unit, isolate the unit from normal read and write operations to prevent further write attempts, and select a healthy spare block from the spare block pool to remap the logical address to the new spare block; for example, when the system determines that the storage medium can be completely written to the coded data block, the system will consider that the coded data block itself is damaged, resulting in the failure of the write operation to be completed smoothly, and ... If the data block is not damaged, the system will detect whether there is an error in the data block, determine the error position and type of the data block based on the comparison result of the check bit, first decode the encoded data block, calculate the data check bit and compare it with the pre-set storage check bit, identify the error attribute in the encoded data block, and use the pre-set Hamming code to locate the specific error bit of the encoded data block based on the comparison result, use the storage check bit to correct the encoded data block, and restore the original data of the encoded data block; the system ensures the integrity of the data after writing by detecting and correcting errors in the data block, and avoids data damage caused by defects in the storage medium. At the same time, through the real-time detection and verification mechanism, the system can detect and correct data errors at an early stage, reduce the risk of data loss due to data damage, and detect and correct storage medium errors in a timely manner, reducing serious failures caused by error accumulation, thereby extending the service life of the storage device.
[0069] It should be noted that the coded data block is decoded, the data check bit is calculated and compared with the preset stored check bit, the error attribute in the coded data block is identified, and the specific example of locating the specific error bit of the coded data block by applying the preset Hamming code according to the comparison result is as follows:
[0070] Assuming there is a data block, using Hamming code to detect and correct single bit errors, the specific steps are as follows:
[0071] The data block consists of 4 data bits and 3 check bits, a total of 7 bits, using the (7,4) Hamming code.
[0072]
[0073] in:
[0074] D1, D2, D3, D4 are data bits
[0075] P1, P2, P3 are check digits
[0076] 1. Encoded data block
[0077] Assuming the initial data block is 1101, the check bits P1, P2, and P3 are calculated using the following formula:
[0078] P1=D1⊕D2⊕D4
[0079] P2=D1⊕D3⊕D4
[0080] P3=D2⊕D3⊕D4
[0081] Assuming the calculated check bits are P1=1, P2=0, P3=1, the encoded data block is 1101101;
[0082] 2. Storage and Reading
[0083] The encoded data block 1101101 is stored in the memory,
[0084] When reading, suppose a single bit error occurs in the data block for some reason and it becomes 1111101;
[0085] 3. Compare the check digit
[0086] Recalculate the check digit:
[0087] P1=1⊕1⊕1=1
[0088] P2=1⊕1⊕1=1
[0089] P3=1⊕1⊕1=1
[0090] The stored check digit is 101, and the recalculated check digit is 111;
[0091] 4. Identify Error Attributes
[0092] The comparison results indicate an error because the stored check digit and the recalculated check digit do not match;
[0093] 5. Positioning error bit
[0094] The Hamming code locates the specific error bit by calculating the difference between the check bits:
[0095] S1=P1^P1'=1^1=0
[0096] S2=P2^P2'=0^1=1
[0097] S3=P3^P3'=1^1=0
[0098] The position of the error bit is S3S2S1 in binary, which is 2 in decimal.
[0099] 6. Correction of Mistakes
[0100] The error occurs at the second bit of the data block, and it is corrected from 1 to 0. The restored data block is 1101101.
[0101] After error correction, the data block is restored to the correct 1101101, and the original data 1101 is also restored;
[0102] In summary, the system ensures the integrity of data during storage and transmission by automatically detecting and correcting single-bit errors. At the same time, the use of error correction codes such as Hamming codes improves the reliability of the storage system and can automatically correct errors when they occur. The automatic error correction mechanism makes the system more robust and able to cope with errors caused by defects in storage media and environmental changes.
[0103] In this embodiment, the step S3 of constructing a data migration plan for the memory according to the storage unit and the abnormal storage unit includes:
[0104] S31: identifying the pre-selected balancing target units in the memory, matching the balancing target units one by one as the migration objects of the abnormal storage units, and dividing the priority queues of data migration according to the health parameters of the abnormal storage units;
[0105] S32: Determine whether the priority queue matches the least-erase-first strategy;
[0106] S33: If so, establishing migration task information of the abnormal storage unit in the memory, and constructing the data migration plan of each abnormal storage unit according to the migration task information, wherein the migration task information specifically includes a migration path, resource allocation and backup content.
[0107] In this embodiment, the system identifies the pre-selected balancing target units in the memory, matches these balancing target units one by one as the migration objects of the abnormal storage units, divides the priority queues of data migration according to the health parameters of the abnormal storage units, and then the system determines whether the priority queues match the least erase priority policy to execute the corresponding steps; for example, when the system determines that the priority queues of data migration cannot match the least erase priority policy, the system will believe that there are problems with the scheduling and policy of data migration and cannot effectively balance the number of erases and writes of the storage units. The system will check the status of the data migration priority queues. If it is found that the queue resources are insufficient or the queue is full, the queue capacity will be increased or invalid tasks in the queue will be cleared. At the same time, the consistency of the data is regularly checked to ensure that the number of erases and writes and the health parameter data of all storage units are up-to-date and accurate, so as to prevent data anomalies from affecting the execution of the policy, and dynamically adjust the parameters and priority of the least erase priority policy according to the real-time status and usage of the storage units, and adjust the migration policy according to the actual situation. The execution effect of the task continuously optimizes the strategy; for example, when the system determines that the priority queue of data migration can match the least erase priority strategy, the system will consider the scheduling and strategy of data migration to be normal, and the system will establish the migration task information of the abnormal storage unit in the memory. The migration task information specifically includes the migration path, resource allocation and backup content, and builds the data migration plan for each storage unit based on the migration task information; the system defines the migration path to ensure that the data moves from the source storage unit to the target storage unit in the shortest and most efficient way, reducing the migration time and resource consumption. At the same time, a backup plan is formulated during the migration process to ensure that data can be restored even in unexpected situations, protecting data integrity and security, and balancing the erase times of each storage unit through the least erase priority strategy, extending the service life of the storage unit, and improving the overall performance and reliability of the system. Through reasonable task scheduling and resource allocation, the system can more flexibly respond to changes and expansions in storage requirements, and also improve the scalability of the system.
[0108] In this embodiment, the step S2 of determining whether the number of erasure times can be updated in real time further includes:
[0109] S21: Based on a preset cache size of the memory, an array structure is applied to store the erase and write times, erase and write operation events are collected in real time, the erase and write times are updated to a preset cache, and the erase and write times of the storage unit are maintained in the cache;
[0110] S22: Determine whether the number of erasures reaches a preset threshold;
[0111] S23: If so, trigger the preset batch update mechanism, write the erase and write times in the cache in batches to the database preset in the memory, and record the erase and write times in the cache in the log file preset in the memory by appending the records, and regularly verify the erase and write consistency between the database and the log file.
[0112] In this embodiment, the system applies a data structure to store the erase and write counts based on a preset cache size of the memory, collects erase and write operation events in real time, updates these erase and write operation events to a preset cache, maintains the erase and write counts of the storage unit in the cache, and then determines whether the erase and write counts have reached a preset threshold to execute corresponding steps; for example, when the system determines that the erase and write counts of the storage unit have not reached the preset threshold, the system will consider that these storage units have not reached the stage of overuse relatively speaking, and are still in a relatively healthy and durable state, the system will continue to monitor the erase and write counts and other health parameters of these storage units to ensure that they remain within the normal use range, and at the same time optimize the use strategy and planning of the memory according to the current erase and write counts, including re-evaluating the storage location of the data, optimizing the data migration strategy, or adjusting the distribution of write operations to extend the service life of the overall memory, and regularly check the health status of the memory, perform necessary firmware updates or patches to ensure the stability and reliability of the system, and establish a complete data backup and recovery strategy to prevent accidental data. The system can also prevent the impact of data loss or sudden damage to the storage unit; for example, when the system determines that the number of erase and write times of the storage unit has reached a preset threshold, the system will consider that the storage unit may be overused, and the system will trigger a preset batch update mechanism to write the erase and write times in the cache into a preset database of the storage device, and record the erase and write times in the cache in a pre-set log file of the storage device by appending, and regularly verify the erase and write consistency between the database and the log file; the system writes the erase and write times of the storage unit and related information into a preset database in batches to ensure that these important data can be stored for a long time and can be quickly queried and analyzed, and writes the erase and write times records into the log file by appending to ensure a complete record of the operation, which is convenient for subsequent auditing and analysis, and regularly verifies whether the erase and write times recorded in the database are consistent with the appended write records in the log file, thereby ensuring the consistency and integrity of the data, and through the preset batch update mechanism and regular verification steps, the system can automatically manage the erase and write times data of the storage unit to reduce the possibility of manual intervention and errors.
[0113] In this embodiment, the step S4 of determining whether the health parameter is within a preset parameter range further includes:
[0114] S41: identifying a current operating environment of the memory, and acquiring a preset parameter level of the memory based on the current operating environment, wherein the parameter level specifically includes a low level, a medium level, and a high level;
[0115] S42: Determine whether the parameter level meets the current operating environment;
[0116] S43: If not, activate the pre-built rule engine in the memory, input the health parameters into the rule engine for rule matching, generate rule conditions that meet the parameter level, and execute the rule conditions according to the current operating environment and the parameter level, wherein the rule conditions specifically include security scans, data snapshots, and aggregated logs.
[0117] In this embodiment, the system identifies the current operating environment of the memory, obtains a pre-set parameter level of the memory based on the current operating environment, and the parameter levels specifically include low level, medium level and high level, and then the system determines whether the parameter level meets the current operating environment to execute the corresponding steps; for example, when the system determines that the parameter level of the memory can meet the current operating environment, the system will consider that the hardware and software configuration, performance requirements and operating environment of the memory have been correctly set and adjusted to meet the optimal conditions for the current system operation, and the system will verify the stability and reliability of the memory at the current parameter level, evaluate the performance of the memory at the current parameter level, including read and write speed and response time, to ensure that the system's performance requirements can be met, and continuously monitor the operating status and health parameters of the memory, such as temperature, erase and write times and error rate, as well as the load of the operating system, and regularly perform preventive maintenance of the memory, including cleaning and checking hardware devices, updating and optimizing software configurations, to extend the service life and performance of the memory; for example, when the system determines that the memory When the parameter level cannot meet the current operating environment, the system will think that the storage is difficult to meet the optimal conditions for the current system operation. The system will activate the pre-built rule engine of the storage, input the health parameters into the rule engine for rule matching, and generate rule conditions that meet the parameter level. The rule conditions specifically include security scanning, data snapshots and aggregate logs, and the rule conditions are executed according to the current operating environment and parameter levels; the rule engine matches the health parameters of the storage to generate rule conditions that meet the current parameter level. This method can dynamically adjust the operation strategy and configuration of the storage according to the real-time health parameter conditions to adapt to the current operating environment requirements. At the same time, according to the data snapshot rule conditions generated by the rule engine, snapshot backups of the storage data are created regularly to ensure the integrity and reliability of the data so that it can be quickly restored when needed, and the aggregate log rule conditions are executed to comprehensively record and analyze the operations and events of the storage. Through the aggregate log, the operating status and performance of the storage can be better understood, potential problems can be discovered in time, and optimization adjustments can be made.
[0118] In this embodiment, the step S1 of using the erasure and writing endurance technical table to record the erasure and writing endurance of the storage unit includes:
[0119] S11: based on the update cycle preset in the erasable number of technical tables, generating a timestamp corresponding to the current update, synchronizing the timestamp to the erasable number of technical tables, and retaining at least one timestamp within a preset period of time from the erasable number of technical tables;
[0120] S12: Determine whether the timestamp matches the number of erase / write times of the memory updated at that time;
[0121] S13: If yes, triggering a preset erase / write operation event of the memory, and distinguishing the corresponding storage unit record in the erase / write times technical table according to the response duration of the erase / write operation event.
[0122] In this embodiment, the system generates a timestamp corresponding to the current update based on the update cycle preset in the erasure frequency technical table, synchronizes the timestamp to the erasure frequency technical table, retains at least one timestamp within a preset time period from the erasure frequency technical table, and then the system determines whether these timestamps match the erasure frequency of the memory updated at that time to execute the corresponding steps; for example, when the system determines that the timestamp cannot match the erasure frequency of the memory updated at that time, the system will consider that it is impossible to accurately track or record the erasure operation on the memory, and the system will check the system log and operation record to confirm the most recent update of the erasure frequency and timestamp to locate the cause of the problem, and at the same time perform a comprehensive inspection of the memory hardware to check for possible hardware failures or damage, and restore the erasure frequency record from the most recent backup, record the erasure frequency and timestamp information at multiple locations to ensure that single point failures do not lead to data inconsistency; for example, when the system When it is determined that the timestamp can match the erase and write times of the memory updated at that time, the system will think that it can track or record the erase and write operations on the memory, and the system will trigger the erase and write operation event pre-set for the detection memory, and distinguish the corresponding storage unit records in the erase and write times technical table according to the response time of the erase and write operation event; by matching the timestamp with the erase and write times, the system can accurately track each erase and write operation, ensure that the records in the erase and write times technical table are consistent with the actual operation, improve the accuracy of data records, effectively avoid data recording errors caused by timestamp mismatch, ensure accurate management of the erase and write times of the storage unit, and detect erase and write operation events in real time, timely distinguish and update the records of the corresponding storage units according to the response time of the erase and write operation, to ensure stable operation of the system, and distinguish the storage unit records in the erase and write times technical table by the response time, which is helpful to analyze the performance of different storage units and optimize the storage management strategy.
[0123] Reference Figure 2 , a dynamic wear leveling system for a flash memory in one embodiment of the present invention, comprising:
[0124] The recording module 10 is used to initialize a preset erasure and writing times technical table of the storage unit based on a preset monitoring script of the storage unit, and use the preset erasure and writing times technical table to record the erasure and writing times of the storage unit;
[0125] A judging module 20, used to judge whether the erasing and writing times can be updated in real time;
[0126] An execution module 30 is used to detect the operation data of the memory, if possible, update the erasure times of the memory unit according to the operation data, apply a preset minimum erasure priority strategy to identify the abnormal memory unit with a difference in the erasure times, build a data migration plan for the memory according to the memory unit and the abnormal memory unit, migrate the pre-stored data from the abnormal memory unit to the memory unit through the data migration plan, and monitor the health parameters of the memory unit and the abnormal memory unit in real time, wherein the operation data specifically includes write operation and erase operation, and the health parameters specifically include the number of bad blocks, read and write delay, and refresh cycle;
[0127] A second determination module 40 is used to determine whether the health parameter is within a preset parameter range;
[0128] The second execution module 50 is used to apply a pre-built prediction model to predict the storage unit and the abnormal storage unit if not, identify the failed unit from the memory based on the prediction result, mark the failed unit on the memory, dynamically allocate a preset spare block from the memory according to the failed unit, replace the failed unit with the spare block, adjust the block mapping table of the memory, remap the logical address of the block mapping table to the spare block, update the metadata of the memory according to the logical address, and point the metadata from the failed unit to the corresponding spare block.
[0129] In this embodiment, the recording module 10 initializes the preset erase and write count technical table of the storage unit based on the monitoring script preset in the flash memory, and uses the erase and write count technical table to record the erase and write count of the storage unit, and then the judgment module 20 judges whether the erase and write count can be updated in real time to execute the corresponding steps; for example, when the system determines that the erase and write count of the storage unit cannot be updated in real time, the system will believe that the storage unit may be physically damaged or close to the end of its life, resulting in unstable erase and write operations. The system will check the system load, configure the load distribution strategy of the erase and write count update task in the load balancer, optimize the resource allocation of key tasks, ensure that high-priority tasks can be executed in a timely manner, and perform a health check on the storage unit at the same time. , evaluate its physical state, check and analyze system logs, locate the cause of storage failure, and review the current data consistency solution, implement distributed transactions or consistency protocols, ensure the reliability of data update operations, and introduce conflict detection mechanisms to handle concurrent conflicts; for example, when the system determines that the number of erase and write times of a storage unit can be updated in real time, the execution module 30 will consider that the storage unit can be used normally, and the system will detect the operation data of the storage unit, which specifically includes write operations and erase operations. The erase and write times of the storage unit are updated according to these operation data, and the pre-set minimum erase and write priority strategy is applied to identify abnormal storage units with different erase and write times, and a data migration plan for the storage unit is constructed based on the storage unit and the abnormal storage unit. The system uses a data migration plan to migrate pre-stored data from abnormal storage units to storage units, and monitors the health parameters of storage units and abnormal storage units in real time. The health parameters include the number of bad blocks, read and write delays, and refresh cycles. The system quickly captures each write and erase operation and updates the erase count in real time to ensure that the usage of each storage unit is reflected in the technical table in a timely manner. At the same time, it uses strategies to identify abnormal storage units with large differences in erase counts to optimize the use of storage units and avoid overuse of certain units. It also builds a data migration plan to migrate data from abnormal units to healthy units, protect data integrity, avoid data loss due to unit failure, discover storage unit anomalies in advance, and take preventive measures. Maintenance; then the second judgment module 40 judges whether the health parameters of the storage unit and the abnormal storage unit are within the preset parameter range to execute the corresponding steps; for example, when the system determines that the health parameters of the storage unit and the abnormal storage unit can be within the preset parameter range, the system will consider that the operating status and performance of these units are normal and in a healthy state, and no immediate repair or replacement operation is required. The system will continue to monitor the health parameters of the storage unit and the abnormal storage unit in real time to timely discover and handle new problems, and regularly back up data to ensure that data can be restored in the event of an unexpected failure, and record all operation and monitoring data in the database for long-term analysis and problem tracking;For example, when the system determines that the health parameters of the storage unit and the abnormal storage unit are not within the preset parameter range, the second execution module 50 will consider that the operation status and performance of these units are abnormal, and the system will use the pre-built prediction model to predict the storage unit and the abnormal storage unit, identify the failed unit from the memory based on the prediction result, mark these failed units on the memory, dynamically allocate pre-set spare blocks from the memory according to each failed unit, replace these failed units with these spare blocks, adjust the block mapping table of the memory, remap the logical address of the block mapping table to the spare block, update the metadata of the memory according to the logical address, and point the metadata from the failed unit to the corresponding spare block; the system identifies the failed unit in advance through the prediction model, marks and processes it to intervene in advance, avoid data loss or system crash caused by unit failure, and dynamically adjust the spare block allocation according to the actual situation by dynamically allocating spare blocks to replace the failed unit, improve the system adaptability, remap the logical address, maintain the consistency of the system data structure, ensure the stable operation of the system, update the metadata to ensure that it points to the correct storage location, and ensure the overall reliability of the system and the accuracy of data access. ;
[0130] In this embodiment, it also includes:
[0131] A generating module, configured to perform an encoding operation on a pre-input data block, generate at least one data check bit, combine the data check bit with the data block to form an encoded data block, and write the encoded data block into a storage medium;
[0132] A third judgment module is used to judge whether the storage medium is completely written;
[0133] The third execution module is used to decode the encoded data block, calculate the data check bit and compare it with the preset storage check bit, identify the error attribute in the encoded data block, apply the preset Hamming code to locate the specific error bit of the encoded data block according to the comparison result, use the storage check bit to correct the encoded data block, and restore the original data of the encoded data block, wherein the error attribute specifically includes the error position and the error type.
[0134] In this embodiment, the system performs an encoding operation on a pre-input data block, generates at least one data check bit, and combines the data check bit with the data block to form a coded data block, writes the coded data block into a storage medium, and then the system determines whether the storage medium is completely written to execute the corresponding steps; for example, when the system determines that the storage medium cannot be completely written to the coded data block, the system will consider that the coded data block itself may be damaged, resulting in the failure of the write operation to be completed smoothly, and the system will wait for a while and then re-execute the write operation to observe whether it is successful. At the same time, the storage unit that cannot be written is marked as a faulty unit, and the unit is isolated from normal read and write operations to prevent further write attempts, and a healthy spare block is selected from the spare block pool to remap the logical address to the new spare block; for example, when the system determines that the storage medium can be completely written to the coded data block, the system will consider that the coded data block itself is damaged, resulting in the failure of the write operation to be completed smoothly, and the system will wait for a while and then re-execute the write operation to observe whether it is successful. At the same time, the system will mark the storage unit that cannot be written as a faulty unit, isolate the unit from normal read and write operations to prevent further write attempts, and select a healthy spare block from the spare block pool to remap the logical address to the new spare block; for example, when the system determines that the storage medium can be completely written to the coded data block, the system will consider that the coded data block itself is damaged, resulting in the failure of the write operation to be completed smoothly, and ... If the data block is not damaged, the system will detect whether there is an error in the data block, determine the error position and type of the data block based on the comparison result of the check bit, first decode the encoded data block, calculate the data check bit and compare it with the pre-set storage check bit, identify the error attribute in the encoded data block, and use the pre-set Hamming code to locate the specific error bit of the encoded data block based on the comparison result, use the storage check bit to correct the encoded data block, and restore the original data of the encoded data block; the system ensures the integrity of the data after writing by detecting and correcting errors in the data block, and avoids data damage caused by defects in the storage medium. At the same time, through the real-time detection and verification mechanism, the system can detect and correct data errors at an early stage, reduce the risk of data loss due to data damage, and detect and correct storage medium errors in a timely manner, reducing serious failures caused by error accumulation, thereby extending the service life of the storage device.
[0135] In this embodiment, the execution module includes:
[0136] an identification submodule, configured to identify pre-selected balancing target units in the memory, match the balancing target units one by one as migration objects of the abnormal storage units, and divide the priority queues of data migration according to the health parameters of the abnormal storage units;
[0137] A judgment submodule, used for judging whether the priority queue matches the least-erase-first strategy;
[0138] The execution submodule is used to establish the migration task information of the abnormal storage unit in the memory, and construct the data migration plan of each abnormal storage unit according to the migration task information, wherein the migration task information specifically includes the migration path, resource allocation and backup content.
[0139] In this embodiment, the system identifies the pre-selected balancing target units in the memory, matches these balancing target units one by one as the migration objects of the abnormal storage units, divides the priority queues of data migration according to the health parameters of the abnormal storage units, and then the system determines whether the priority queues match the least erase priority policy to execute the corresponding steps; for example, when the system determines that the priority queues of data migration cannot match the least erase priority policy, the system will believe that there are problems with the scheduling and policy of data migration and cannot effectively balance the number of erases and writes of the storage units. The system will check the status of the data migration priority queues. If it is found that the queue resources are insufficient or the queue is full, the queue capacity will be increased or invalid tasks in the queue will be cleared. At the same time, the consistency of the data is regularly checked to ensure that the number of erases and writes and the health parameter data of all storage units are up-to-date and accurate, so as to prevent data anomalies from affecting the execution of the policy, and dynamically adjust the parameters and priority of the least erase priority policy according to the real-time status and usage of the storage units, and adjust the migration policy according to the actual situation. The execution effect of the task continuously optimizes the strategy; for example, when the system determines that the priority queue of data migration can match the least erase priority strategy, the system will consider the scheduling and strategy of data migration to be normal, and the system will establish the migration task information of the abnormal storage unit in the memory. The migration task information specifically includes the migration path, resource allocation and backup content, and builds the data migration plan for each storage unit based on the migration task information; the system defines the migration path to ensure that the data moves from the source storage unit to the target storage unit in the shortest and most efficient way, reducing the migration time and resource consumption. At the same time, a backup plan is formulated during the migration process to ensure that data can be restored even in unexpected situations, protecting data integrity and security, and balancing the erase times of each storage unit through the least erase priority strategy, extending the service life of the storage unit, and improving the overall performance and reliability of the system. Through reasonable task scheduling and resource allocation, the system can more flexibly respond to changes and expansions in storage requirements, and also improve the scalability of the system.
[0140] In this embodiment, the judgment module further includes:
[0141] A maintenance submodule, for storing the erasure times using an array structure based on a preset cache size of the memory, collecting erasure operation events in real time, updating the erasure times to a preset cache, and maintaining the erasure times of the storage unit in the cache;
[0142] A second judgment submodule is used to judge whether the number of erasure and writing times reaches a preset threshold;
[0143] The second execution sub-module is used to trigger the preset batch update mechanism if so, batch write the erase and write times in the cache to the database preset in the memory, and record the erase and write times in the cache to the log file preset in the memory by appending the records, and regularly verify the erase and write consistency between the database and the log file.
[0144] In this embodiment, the system applies a data structure to store the erase and write counts based on a preset cache size of the memory, collects erase and write operation events in real time, updates these erase and write operation events to a preset cache, maintains the erase and write counts of the storage unit in the cache, and then determines whether the erase and write counts have reached a preset threshold to execute corresponding steps; for example, when the system determines that the erase and write counts of the storage unit have not reached the preset threshold, the system will consider that these storage units have not reached the stage of overuse relatively speaking, and are still in a relatively healthy and durable state, the system will continue to monitor the erase and write counts and other health parameters of these storage units to ensure that they remain within the normal use range, and at the same time optimize the use strategy and planning of the memory according to the current erase and write counts, including re-evaluating the storage location of the data, optimizing the data migration strategy, or adjusting the distribution of write operations to extend the service life of the overall memory, and regularly check the health status of the memory, perform necessary firmware updates or patches to ensure the stability and reliability of the system, and establish a complete data backup and recovery strategy to prevent accidental data. The system can also prevent the impact of data loss or sudden damage to the storage unit; for example, when the system determines that the number of erase and write times of the storage unit has reached a preset threshold, the system will consider that the storage unit may be overused, and the system will trigger a preset batch update mechanism to write the erase and write times in the cache into a preset database of the storage device, and record the erase and write times in the cache in a pre-set log file of the storage device by appending, and regularly verify the erase and write consistency between the database and the log file; the system writes the erase and write times of the storage unit and related information into a preset database in batches to ensure that these important data can be stored for a long time and can be quickly queried and analyzed, and writes the erase and write times records into the log file by appending to ensure a complete record of the operation, which is convenient for subsequent auditing and analysis, and regularly verifies whether the erase and write times recorded in the database are consistent with the appended write records in the log file, thereby ensuring the consistency and integrity of the data, and through the preset batch update mechanism and regular verification steps, the system can automatically manage the erase and write times data of the storage unit to reduce the possibility of manual intervention and errors.
[0145] In this embodiment, the second determination module further includes:
[0146] A second identification submodule, used to identify the current operating environment of the memory, and obtain a preset parameter level of the memory based on the current operating environment, wherein the parameter level specifically includes a low level, a medium level, and a high level;
[0147] A third judgment submodule is used to judge whether the parameter level conforms to the current operating environment;
[0148] The third execution submodule is used to activate the pre-built rule engine in the memory if not, input the health parameters into the rule engine for rule matching, generate rule conditions that meet the parameter level, and execute the rule conditions according to the current operating environment and the parameter level, wherein the rule conditions specifically include security scans, data snapshots, and aggregated logs.
[0149] In this embodiment, the system identifies the current operating environment of the memory, obtains a pre-set parameter level of the memory based on the current operating environment, and the parameter levels specifically include low level, medium level and high level, and then the system determines whether the parameter level meets the current operating environment to execute the corresponding steps; for example, when the system determines that the parameter level of the memory can meet the current operating environment, the system will consider that the hardware and software configuration, performance requirements and operating environment of the memory have been correctly set and adjusted to meet the optimal conditions for the current system operation, and the system will verify the stability and reliability of the memory at the current parameter level, evaluate the performance of the memory at the current parameter level, including read and write speed and response time, to ensure that the system's performance requirements can be met, and continuously monitor the operating status and health parameters of the memory, such as temperature, erase and write times and error rate, as well as the load of the operating system, and regularly perform preventive maintenance of the memory, including cleaning and checking hardware devices, updating and optimizing software configurations, to extend the service life and performance of the memory; for example, when the system determines that the memory When the parameter level cannot meet the current operating environment, the system will think that the storage is difficult to meet the optimal conditions for the current system operation. The system will activate the pre-built rule engine of the storage, input the health parameters into the rule engine for rule matching, and generate rule conditions that meet the parameter level. The rule conditions specifically include security scanning, data snapshots and aggregate logs, and the rule conditions are executed according to the current operating environment and parameter levels; the rule engine matches the health parameters of the storage to generate rule conditions that meet the current parameter level. This method can dynamically adjust the operation strategy and configuration of the storage according to the real-time health parameter conditions to adapt to the current operating environment requirements. At the same time, according to the data snapshot rule conditions generated by the rule engine, snapshot backups of the storage data are created regularly to ensure the integrity and reliability of the data so that it can be quickly restored when needed, and the aggregate log rule conditions are executed to comprehensively record and analyze the operations and events of the storage. Through the aggregate log, the operating status and performance of the storage can be better understood, potential problems can be discovered in time, and optimization adjustments can be made.
[0150] In this embodiment, the recording module further includes:
[0151] A synchronization submodule, for generating a timestamp corresponding to the current update based on the preset update cycle of the erasable number of technical tables, synchronizing the timestamp to the erasable number of technical tables, and retaining at least one timestamp within a preset period of time from the erasable number of technical tables;
[0152] A fourth judgment submodule, used to judge whether the timestamp matches the number of erasures and writes of the memory updated at that time;
[0153] The fourth execution submodule is used to trigger a preset erase and write operation event of the memory if yes, and distinguish the corresponding storage unit record in the erase and write times technical table according to the response time of the erase and write operation event.
[0154] In this embodiment, the system generates a timestamp corresponding to the current update based on the update cycle preset in the erasure frequency technical table, synchronizes the timestamp to the erasure frequency technical table, retains at least one timestamp within a preset time period from the erasure frequency technical table, and then the system determines whether these timestamps match the erasure frequency of the memory updated at that time to execute the corresponding steps; for example, when the system determines that the timestamp cannot match the erasure frequency of the memory updated at that time, the system will consider that it is impossible to accurately track or record the erasure operation on the memory, and the system will check the system log and operation record to confirm the most recent update of the erasure frequency and timestamp to locate the cause of the problem, and at the same time perform a comprehensive inspection of the memory hardware to check for possible hardware failures or damage, and restore the erasure frequency record from the most recent backup, record the erasure frequency and timestamp information at multiple locations to ensure that single point failures do not lead to data inconsistency; for example, when the system When it is determined that the timestamp can match the erase and write times of the memory updated at that time, the system will think that it can track or record the erase and write operations on the memory, and the system will trigger the erase and write operation event pre-set for the detection memory, and distinguish the corresponding storage unit records in the erase and write times technical table according to the response time of the erase and write operation event; by matching the timestamp with the erase and write times, the system can accurately track each erase and write operation, ensure that the records in the erase and write times technical table are consistent with the actual operation, improve the accuracy of data records, effectively avoid data recording errors caused by timestamp mismatch, ensure accurate management of the erase and write times of the storage unit, and detect erase and write operation events in real time, timely distinguish and update the records of the corresponding storage units according to the response time of the erase and write operation, to ensure stable operation of the system, and distinguish the storage unit records in the erase and write times technical table by the response time, which is helpful to analyze the performance of different storage units and optimize the storage management strategy.
[0155] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A dynamic wear leveling method for flash memory, It is characterized in that The following steps are involved: Initialize a preset erasure and writing times technical table of the storage unit based on a preset monitoring script of the storage unit, and use the preset erasure and writing times technical table to record the erasure and writing times of the storage unit; Determine whether the number of erase and write times can be updated in real time; If it is possible, then detect the operation data of the memory, update the erasure times of the memory unit according to the operation data, apply a preset minimum erasure priority strategy to identify the abnormal memory unit with a difference in the erasure times, build a data migration plan for the memory according to the memory unit and the abnormal memory unit, migrate the pre-stored data from the abnormal memory unit to the memory unit through the data migration plan, and monitor the health parameters of the memory unit and the abnormal memory unit in real time, wherein the operation data specifically includes write operation and erase operation, and the health parameters specifically include the number of bad blocks, read and write delay, and refresh cycle; If not, the storage unit is physically damaged or near the end of its life; Determining whether the health parameter is within a preset parameter range; If not, a pre-built prediction model is applied to predict the storage unit and the abnormal storage unit, a failed unit is identified from the storage unit based on the prediction result, the failed unit is marked on the storage unit, a preset spare block is dynamically allocated from the storage unit according to the failed unit, the failed unit is replaced by the spare block, a block mapping table of the storage unit is adjusted, a logical address of the block mapping table is remapped to the spare block, metadata of the storage unit is updated according to the logical address, and the metadata is pointed from the failed unit to the corresponding spare block; If so, the operating status and performance of the storage unit and the abnormal storage unit are normal.
2. The dynamic wear leveling method of the flash memory according to claim 1, It is characterized in that Before the step of applying the preset minimum erase and write priority strategy to identify the abnormal storage unit with different erase and write times, the method further includes: Performing an encoding operation on a pre-input data block to generate at least one data check bit, combining the data check bit with the data block to form an encoded data block, and writing the encoded data block into a storage medium; Determining whether the storage medium is completely written; If so, decode the encoded data block, calculate the data check bit and compare it with the preset storage check bit, identify the error attribute in the encoded data block, apply the preset Hamming code to locate the specific error bit of the encoded data block according to the comparison result, use the storage check bit to correct the encoded data block, and restore the original data of the encoded data block, wherein the error attribute specifically includes the error position and the error type.
3. The dynamic wear leveling method of the flash memory according to claim 1, It is characterized in that The step of constructing a data migration plan for the memory according to the storage unit and the abnormal storage unit includes: Identify pre-selected balancing target units in the memory, match the balancing target units one by one as migration objects of the abnormal storage unit, and divide the priority queues of data migration according to the health parameters of the abnormal storage unit; Determining whether the priority queue matches the least-erase-first strategy; If so, the migration task information of the abnormal storage unit in the memory is established, and the data migration plan of each abnormal storage unit is constructed according to the migration task information, wherein the migration task information specifically includes a migration path, resource allocation and backup content.
4. The dynamic wear leveling method of the flash memory according to claim 1, It is characterized in that The step of determining whether the number of erasures and writes can be updated in real time also includes: Based on the preset cache size of the memory, an array structure is applied to store the erasure times, erasure operation events are collected in real time, the erasure times are updated to the preset cache, and the erasure times of the storage unit are maintained in the cache; Determining whether the number of erasures and writes reaches a preset threshold; If so, the preset batch update mechanism is triggered, the erase and write counts in the cache are batch-written to the preset database of the memory, and the erase and write counts in the cache are recorded in the preset log file of the memory by appending writes, and the erase and write consistency between the database and the log file is regularly verified.
5. The dynamic wear leveling method of the flash memory according to claim 1, It is characterized in that The step of determining whether the health parameter is within a preset parameter range further includes: Identify the current operating environment of the memory, and obtain a preset parameter level of the memory based on the current operating environment, wherein the parameter level specifically includes a low level, a medium level, and a high level; Determining whether the parameter level meets the current operating environment; If not, activate the pre-built rule engine in the memory, input the health parameters into the rule engine for rule matching, generate rule conditions that meet the parameter level, and execute the rule conditions according to the current operating environment and the parameter level, wherein the rule conditions specifically include security scans, data snapshots, and aggregated logs.
6. The dynamic wear leveling method of the flash memory according to claim 1, It is characterized in that The step of applying the erasure and writing number technical table to record the erasure and writing number of the storage unit includes: Based on the update cycle preset in the erasable number of technology table, generate a timestamp corresponding to the current update, synchronize the timestamp to the erasable number of technology table, and retain at least one timestamp within a preset period of time from the erasable number of technology table; Determine whether the timestamp matches the number of erase / write times of the memory updated at that time; If so, a preset erase / write operation event of the memory is triggered, and the corresponding storage unit record in the erase / write times technical table is distinguished according to the response duration of the erase / write operation event.
7. A dynamic wear leveling system for flash memory, It is characterized in that include: A recording module, used for initializing a preset erasure and writing times technical table of the storage unit based on a preset monitoring script of the storage unit, and using the preset erasure and writing times technical table to record the erasure and writing times of the storage unit; A judging module, used for judging whether the erasing and writing times can be updated in real time; An execution module, for detecting operation data of the memory, if possible, updating the erasure times of the memory unit according to the operation data, identifying abnormal memory units with different erasure times by applying a preset minimum erasure priority strategy, building a data migration plan for the memory according to the memory unit and the abnormal memory unit, migrating pre-stored data from the abnormal memory unit to the memory unit through the data migration plan, and monitoring health parameters of the memory unit and the abnormal memory unit in real time, wherein the operation data specifically includes write operations and erase operations, and the health parameters specifically include the number of bad blocks, read and write delays, and refresh cycles; A fourth execution module is used for, if not, then the storage unit is physically damaged or close to the end of its life; A second judgment module is used to judge whether the health parameter is within a preset parameter range; a second execution module, for, if not, applying a pre-built prediction model to predict the storage unit and the abnormal storage unit, identifying a failed unit from the storage unit based on the prediction result, marking the failed unit on the storage unit, dynamically allocating a preset spare block from the storage unit according to the failed unit, replacing the failed unit with the spare block, adjusting a block mapping table of the storage unit, remapping a logical address of the block mapping table to the spare block, updating metadata of the storage unit according to the logical address, and pointing the metadata from the failed unit to the corresponding spare block; A fifth execution module is used to determine that if so, the operating status and performance of the storage unit and the abnormal storage unit are normal.
8. The dynamic wear leveling system of the flash memory according to claim 7, It is characterized in that Also includes: A generating module, configured to perform an encoding operation on a pre-input data block, generate at least one data check bit, combine the data check bit with the data block to form an encoded data block, and write the encoded data block into a storage medium; A third judgment module is used to judge whether the storage medium is completely written; The third execution module is used to decode the encoded data block, calculate the data check bit and compare it with the preset storage check bit, identify the error attribute in the encoded data block, apply the preset Hamming code to locate the specific error bit of the encoded data block according to the comparison result, use the storage check bit to correct the encoded data block, and restore the original data of the encoded data block, wherein the error attribute specifically includes the error position and the error type.
9. The dynamic wear leveling system of the flash memory according to claim 7, It is characterized in that The execution module includes: an identification submodule, configured to identify pre-selected balancing target units in the memory, match the balancing target units one by one as migration objects of the abnormal storage units, and divide the priority queues of data migration according to the health parameters of the abnormal storage units; A judgment submodule, used for judging whether the priority queue matches the least-erase-first strategy; The execution submodule is used to establish the migration task information of the abnormal storage unit in the memory, and construct the data migration plan of each abnormal storage unit according to the migration task information, wherein the migration task information specifically includes the migration path, resource allocation and backup content.
Citation Information
Patent Citations
Four-pool flash wear leveling method
CN102789423A
Self-adaptive storage device loss balancing method and system
CN110851079A
Storage device with improved durability
CN114651227A
Flash memory data management method, storage device controller and storage device
CN115552383A
Resting blocks of memory cells in response to the blocks being deemed to fail
US20150033087A1
