Disclosure of Invention
Aiming at the defects of the prior art, the invention aims to provide a self-adaptive storage device wear leveling method and a self-adaptive storage device wear leveling system, and aims to solve the problem that the existing storage medium wear leveling processing method cannot reasonably distribute the erasing times of each storage unit, so that the service life of a storage device is short.
To achieve the above object, in one aspect, the present invention provides an adaptive wear leveling method for a storage device, including:
(1) performing quality evaluation on the nonvolatile memory through a memory cell quality model, and establishing a quality evaluation table with a memory cell as a unit based on a quality evaluation result;
(2) judging whether the quantization quality difference between the storage unit with the optimal quality and the storage unit with the worst quality in the quality evaluation table meets a threshold condition or not, and executing the step (3); otherwise, executing the step (4);
(3) resetting the use priority of the storage unit according to the quality evaluation table, and turning to the step (4);
(4) after receiving a data command, erasing and writing the storage unit with the highest use priority, and updating a quality evaluation table and characteristic data corresponding to the storage unit; turning to the step (5);
(5) judging whether each storage unit meets preset conditions or not based on the erasing and writing of the storage units in the step (4), inputting the characteristic data into the quality model of the storage unit to update the quality evaluation table corresponding to the storage unit, and turning to the step (6); the storage unit which does not meet the preset condition is switched to the step (2);
(6) judging whether the storage equipment is normally used, if so, turning to the step (2); otherwise, the execution is stopped. Preferably, the storage unit quality model is a function model or a neural network model or a gene programming model or an artificial intelligence model;
preferably, the storage unit quality model is implemented as: a programmed implementation or a hardware circuit implementation or a programmed hardware hybrid implementation.
Preferably, the method for establishing the storage unit quality model comprises the following steps: and establishing the characteristic data in the training storage unit by a machine learning method.
Preferably, the characteristic data of the storage unit includes: programming time, reading time, erasing time, current, chip power consumption, threshold voltage distribution, memory cell number, memory page number, the number of program/erase cycles of the memory cell in the current period, the number of conditional error pages, the number of conditional error blocks, the number of error bits, and the error rate.
Preferably, the characteristic data acquisition of the storage unit and the updating of the quality evaluation table are performed when a controller of the storage device is in an idle state;
note that the controller is a processor inherent in the storage device, is a basic concept in the field, and generally has functions of reading, writing, erasing, wear leveling, defragmentation, and the like;
preferably, the preset condition is that the erasing times of the storage unit exceed a preset threshold;
preferably, the preset condition is that the difference value between the service life of the unit with the optimal quality and the service life of the unit with the worst quality in the storage unit is greater than a preset threshold value;
preferably, the preset condition is that the error rate of the storage unit exceeds a preset threshold;
preferably, the preset condition is that the variation of the operation time (read, write, erase) of the memory cell exceeds a preset threshold.
In another aspect, the present invention provides an adaptive wear leveling system for a storage device, including: the device comprises a data acquisition module, a quality evaluation module, an information storage module, a storage unit loss balance judgment module and a storage unit data migration module which are sequentially connected; the quality evaluation module is used for inputting the characteristic data of the storage unit into the storage unit quality model and updating and establishing a quality evaluation table for the storage unit;
the data acquisition module is used for acquiring the characteristic data of the storage unit;
the information storage module is used for storing the quality evaluation table of each storage unit;
the storage unit loss balance judging module is used for judging whether the quantization quality difference between the storage unit with the optimal quality and the storage unit with the worst quality in the quality evaluation table meets a threshold condition or not;
the storage unit data migration module is used for setting the use priority for the storage unit.
Preferably, the storage unit data migration module is used for storing hot data in a storage unit with better quality than cold data in a quality evaluation table; that is, hot data requiring long-time update is stored in a storage unit with better quality, and cold data with low update frequency is stored in a storage unit with poorer quality.
Preferably, the memory cell quality model is a function model or a neural network model or a genetic programming model or an artificial intelligence model.
Preferably, the characteristic data of the storage unit includes: programming time, reading time, erasing time, current, chip power consumption, threshold voltage distribution, memory cell number, memory page number, the number of program/erase cycles of the memory cell in the current period, the number of conditional error pages, the number of conditional error blocks, the number of error bits, and the error rate.
Through the technical scheme, compared with the prior art, the invention has the following beneficial effects:
(1) before erasing and writing the memory units, judging whether the quantization quality difference between the memory unit with the optimal quality and the memory unit with the worst quality in the quality evaluation table meets a threshold condition or not according to the quality evaluation table corresponding to each memory unit, setting the use priority of the memory units, and fully considering the storage difference of each memory unit; and on the other hand, whether the preset condition is met or not is judged according to erasing and writing of the storage unit, and the quality evaluation table corresponding to the storage unit is updated for the storage unit meeting the preset condition through the storage quality model, so that the use priority of the storage unit is convenient to set. By combining the two aspects, the invention fully considers the erasing times of the storage units, reasonably distributes the erasing execution of each storage unit and prolongs the reliable working time of the storage equipment.
(2) In the invention, whether the preset conditions are met is judged by taking each storage unit as a unit, the quality evaluation table is updated only for the storage unit meeting the preset conditions, but not for the whole nonvolatile memory, and meanwhile, the characteristic data acquisition of the storage unit and the updating of the quality evaluation table are carried out when the controller is in an idle state, so that the resources and the time cost of a self-adaptive storage device loss balancing system are fully saved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In one aspect, as shown in fig. 1, the present invention provides a method for wear leveling of an adaptive storage device, including:
(1) performing quality evaluation on the nonvolatile memory through a memory cell quality model, and establishing a quality evaluation table with a memory cell as a unit based on a quality evaluation result;
(2) judging whether the quantization quality difference between the storage unit with the optimal quality and the storage unit with the worst quality in the quality evaluation table meets a threshold condition or not, and executing the step (3); otherwise, executing the step (4);
(3) resetting the use priority of the storage unit according to the quality evaluation table, and turning to the step (4);
(4) after receiving a data command, erasing and writing the storage unit with the highest use priority, and updating a quality evaluation table and characteristic data corresponding to the storage unit; turning to the step (5);
(5) judging whether the storage unit meets the preset condition or not based on the erasing and writing of the storage unit in the step (4), inputting the characteristic data into the quality model of the storage unit to update the quality evaluation table corresponding to the storage unit in the storage unit meeting the preset condition, and turning to the step (6); the storage unit which does not meet the preset condition is switched to the step (2);
(6) judging whether the storage equipment is normally used, if so, turning to the step (2); otherwise, the execution is stopped.
Preferably, the storage unit quality model is a function model or a neural network model or a gene programming model or an artificial intelligence model;
preferably, the storage unit quality model is implemented as: a programmed implementation or a hardware circuit implementation or a programmed hardware hybrid implementation.
Preferably, the method for establishing the storage unit quality model comprises the following steps: and establishing the characteristic data in the training storage unit by a machine learning method.
Preferably, the characteristic data of the storage unit includes: programming time, reading time, erasing time, current, chip power consumption, threshold voltage distribution, memory cell number, memory page number, the number of program/erase cycles of the memory cell in the current period, the number of conditional error pages, the number of conditional error blocks, the number of error bits, and the error rate.
Preferably, the characteristic data acquisition of the storage unit and the updating of the quality evaluation table are performed in an idle state of a controller of the storage device;
note that the controller is a processor inherent in the storage device, is a basic concept in the field, and generally has functions of reading, writing, erasing, wear leveling, defragmentation, and the like;
in the invention, after the controller receives the data command, the controller controls the memory unit with the highest priority to be erased and written, and judges whether each memory unit meets the preset condition.
Preferably, the preset condition is that the erasing times of the storage unit exceed a preset threshold;
preferably, the preset condition is that the difference value between the service life of the unit with the optimal quality and the service life of the unit with the worst quality in the storage unit is greater than a preset threshold value; preferably, the preset condition is that the error rate of each storage unit exceeds a preset threshold;
preferably, the preset condition is that the variation of the operation time (read, write, erase) of the memory cell exceeds a preset threshold;
examples
The solid state disk under a certain manufacturing process is used as a storage system, and a storage block of a flash memory (NAND flash) under a certain manufacturing process is used as a storage unit.
(1) Performing quality evaluation on the nonvolatile memory through a memory cell quality model, and establishing a quality evaluation table with a memory cell as a unit based on a quality evaluation result;
more specifically, after the storage system is powered on for use, the data acquisition module acquires characteristic data in the training storage unit, and the characteristic data is input into the storage unit quality model; the storage unit quality model carries out quality evaluation on the whole nonvolatile memory, and establishes a quality evaluation table with the storage unit as a unit, wherein the quality evaluation table is stored by the information storage module shown in the figure 2;
preferably, the quality estimation table stores a value of the number of remaining life cycles of the storage unit;
preferably, the characteristic data of the memory block of the flash memory includes: data change information of a program time, an erase time, a threshold voltage distribution and an error rate of a one-time program/erase operation memory block under the condition of increasing program/erase cycles;
the programming time of the flash memory is obtained by the following steps: the data acquisition module records the passed clock period when the flash memory starts to write data, and stops recording the clock period number after receiving a data coding completion mark returned by the flash memory; the programming time is the duration of the clock cycle times the number of programming clock cycles;
the method for acquiring the erasing time of the flash memory is the same as the method for acquiring the programming time, the data acquisition module records the clock period number of the erasing operation, and the erasing time is the time of multiplying the clock period duration by the erasing clock period number;
the method for acquiring the threshold voltage distribution of the flash memory comprises the following steps: the data acquisition module sends a READ-RETRY command set to the flash memory to gradually change the READ reference voltage of the flash memory and simultaneously count threshold voltage distribution according to READ data values.
The error rate of the flash memory is obtained by the following method: the data acquisition module executes data reading operation on the flash memory to read data from the flash memory, compares the read data with written training data to count the number of error data, and the error rate is the number of errors divided by the total number of data;
the method for establishing the storage unit quality model comprises the following steps:
A. firstly, carrying out a preposed test on a flash memory chip to generate data for machine learning; the specific test process is as follows: repeatedly erasing, writing and reading a specific block of the chip, and recording the current, the operation time and the original error bit number in the operation process until the specific block is worn to be invalid; the process only generates a group of training data for machine learning, a large amount of training data is often needed to improve the accuracy of the quality model of the storage unit, and the test method can be repeated;
B. when the training data are enough to ensure the accuracy of the storage unit quality model, inputting the characteristic data obtained in the step A into a training program of the storage unit quality model, and obtaining the storage unit quality model after training; the training program of the storage unit quality model adopts an artificial neural network training program;
C. converting the memory cell quality model obtained by training into a form capable of running in a memory system;
(2) judging whether the quantization quality difference between the storage unit with the optimal quality and the storage unit with the worst quality in the quality evaluation table meets a threshold condition, and if so, executing the step (3); otherwise, executing the step (4);
in this embodiment, the storage system sets a difference threshold of the remaining program/erase life, for example, the difference threshold is set to 500, that is, when the difference between the maximum remaining life and the minimum remaining life is less than 500, the wear leveling operation mapping table is not modified, and the wear leveling operation is performed along the original wear leveling operation; when the difference value between the maximum residual life and the minimum residual life is more than five hundred, updating a wear-leveling operation mapping table according to the quality evaluation table so as to balance the residual life of the flash memory in the whole chip;
wear leveling operation: the storage system performs priority sequencing on the internal blocks of the flash memories according to the quality evaluation table of each flash memory, and preferentially writes the internal blocks with high residual life when data are written or erased; meanwhile, the written data or the erased data are classified, the data are divided into hot data which need to be updated frequently and cold data which do not need to be updated frequently, and the internal blocks with high residual life are preferentially used for storing the hot data in the using process so as to balance the residual life of the internal physical blocks of the whole chip;
(3) resetting the use priority of the storage unit according to the quality evaluation table, and turning to the step (4);
(4) after receiving a data command, erasing and writing the storage unit with the highest use priority, and updating a quality evaluation table and characteristic data corresponding to the storage unit; turning to the step (5);
(5) judging whether each storage unit meets preset conditions or not based on the erasing and writing of the storage units in the step (4), inputting the characteristic data into the quality model of the storage unit to update the quality evaluation table corresponding to the storage unit, and turning to the step (6); the storage unit which does not meet the preset condition is switched to the step (2);
more specifically, each time one flash memory is erased and written, the storage system reduces the remaining life cycle number of the flash memory in the quality evaluation table by one, so as to realize real-time update of the quality evaluation table;
when the preset condition is that one hundred erasing operations are executed, namely the same flash memory executes one hundred erasing operations, the operating current, the operating time and the original error bit number of the erasing operations are obtained, the characteristic data are input into a storage unit quality model, the storage unit quality model recalculates the residual life cycle number of the flash memory storage unit when the controller is in an idle state, and the calculated residual life cycle number is updated to a quality evaluation table;
more specifically, when the storage system runs, a data acquisition module in the storage system collects characteristic data such as operating current, operating time, original error bit number and the like generated by the operation of reading, writing and erasing the storage unit, the storage system stores the collected characteristic data in a specific area, and when the controller is in an idle state, the characteristic data is used as training data of a storage unit quality model, the storage unit quality model is optimized, and the model is updated;
after the storage unit quality model is updated, quality evaluation does not need to be carried out on all flash memories in the whole chip at once, and only after the updating condition of the storage unit residual life cycle number table is finished, life prediction is carried out on the corresponding flash memories again, so that storage system resources can be greatly saved; (6) judging whether the storage equipment is normally used, if so, turning to the step (2); otherwise, the execution is stopped.
In another aspect, as shown in fig. 2, the present invention provides an adaptive wear leveling system for a storage device, including: the device comprises a data acquisition module, a quality evaluation module, an information storage module, a storage unit loss balance judgment module and a storage unit data migration module which are sequentially connected; the quality evaluation module is used for inputting the characteristic data of the storage unit into the storage unit quality model to update and establish a quality evaluation table of the storage unit;
the data acquisition module is used for acquiring the characteristic data of the storage unit;
the information storage module is used for storing the quality evaluation table of each storage unit;
the storage unit loss balance judging module is used for judging whether the quantization quality difference between the storage unit with the optimal quality and the storage unit with the worst quality in the quality evaluation table meets a threshold condition or not;
the storage unit data migration module is used for setting the use priority for the storage unit.
Preferably, the storage unit data migration module is further used for storing the hot data in a storage unit with better quality than the cold data in a quality evaluation table. That is, hot data requiring long time update is put into a memory cell with better quality, and cold data with low update frequency is put into a memory cell with poorer quality.
Preferably, the memory cell quality model is a function model or a neural network model or a genetic programming model or an artificial intelligence model.
Preferably, the characteristic data of the storage unit includes: programming time, reading time, erasing time, current, chip power consumption, threshold voltage distribution, memory cell number, memory page number, the number of program/erase cycles of the memory cell in the current period, the number of conditional error pages, the number of conditional error blocks, the number of error bits, and the error rate.
In summary, according to the adaptive wear leveling method for the storage device provided by the present invention, before erasing and writing the storage units, according to the quality evaluation table corresponding to each storage unit, it is determined whether the quality difference between two users between the storage unit with the best quality and the storage unit with the worst quality in the quality evaluation table satisfies the threshold condition, the usage priority of the storage unit is set, and the storage difference of each storage unit is fully considered; and on the other hand, whether the preset condition is met or not is judged according to erasing and writing of the storage unit, and the quality evaluation table corresponding to the storage unit is updated for the storage unit meeting the preset condition through the storage quality model, so that the setting of the use priority of the storage unit is convenient. By combining the two aspects, the invention fully considers the erasing times of the storage units, reasonably distributes the erasing execution of each storage unit and prolongs the reliable working time of the storage equipment.
In the invention, whether the preset conditions are met is judged by taking each storage unit as a unit, the quality evaluation table is updated only for the storage unit meeting the preset conditions, but not for the whole nonvolatile memory, and meanwhile, the characteristic data acquisition of the storage unit and the updating of the quality evaluation table are carried out when the controller is in an idle state, so that the resources and the time cost of a self-adaptive storage device loss balancing system are fully saved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks.
The computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting the same, and although the present invention is described in detail with reference to the above embodiments, those of ordinary skill in the art should understand that: modifications and equivalents may be made to the embodiments of the invention without departing from the spirit and scope of the invention, which is to be covered by the claims.