Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
As shown in Figure 1, it is the interface synoptic diagram of memory device and other equipment in the embodiment of the invention, I/O101 (IO interface), RAM102 (Random Access Memory, random access memory), system controller 103 are connected by bus 105 with memory device 104.Memory device is by interface chip 1041, and control chip 1042 and storage medium 1043 are formed, and storage medium 1043 can be the Flash chipset, perhaps SDRAM etc.For the those skilled in the art, for other hard disks that comprise the Flash memory device, can use the know-why of the embodiment of the invention equally, use the corresponding techniques scheme, reach identical technique effect.Protection scope of the present invention is not limited to the Flash memory device.
As shown in Figure 2, be storage medium (being specifically as follows the Flash flash chip) the tissue division synoptic diagram of the embodiment of the invention.In each embodiment of the present invention, storage medium can be divided into redundant area and data field two parts, and redundant area is used to deposit mapping table, the erasable count table of piece, bad piece record sheet and grouping information etc., and the data field is used for storaging user data.Mapping table is used to preserve the logical address of data and the corresponding relation of physical address, the erasable count table of piece is used to write down the erasable number of times of each data block place physical address, bad piece record sheet is used to write down bad piece, can use the mode of the physical address at each data block place being made bad piece mark, grouping information is used to write down the physical address etc. of the group at each data block place.During system initialization, above-mentioned each record sheet is read into RAM, and carries out Dynamic Maintenance in RAM, more above-mentioned record sheet is write back the redundant area storage before the power down.The Flash storage medium is made up of the plurality of data piece, and the data block of some is divided into some parts, and every part is exactly one group.The method of the embodiment of the invention can be to carry out on the basis of the These characteristics of Flash storage medium.
The wear leveling strategy of each embodiment of the present invention can be stored in the form of software in the redundant area, reads in RAM after system powers on, and memory device is managed, and each record sheet after will managing before the power down writes back redundant area, to preserve result.
In embodiments of the present invention, the processing procedure of management method can be divided into idle period and data write operation period.As shown in Figure 3, be the embodiment of the invention one, comprise step:
301, phase at one's leisure, by check grouping information table and erasable count table, judging whether needs to trigger the wear leveling strategy, if judged result is for being that then execution in step 302; If judged result is that then execution in step 304;
Wherein, before described inspection grouping information table and the erasable count table, can also comprise:
Reclaim blank block.
Wherein, when reclaiming blank block, the blank block that described recovery is obtained carries out bad block check record.
302, trigger the wear leveling strategy if desired, then the blank block that reclaims is inserted unordered formation;
303, in data write operation period, from described unordered formation, obtain blank block, write data to the described blank block that obtains;
304, behind the termination process, re-execute step 301, trigger the wear leveling strategy next time and judge.
Embodiment of the invention method can be adjusted each sequence of steps according to actual needs.
Utilize the embodiment of the invention, by check grouping information table of phase at one's leisure and erasable count table, judging whether needs to trigger the wear leveling strategy, has overcome the excessive technical matters of system overhead that data write operation is tested and caused period; When judgement needs to trigger the wear leveling strategy, just the blank block that reclaims is inserted unordered formation, use described blank block to write data during for data write operation, thereby carry out the big blank block recovery operation of amount consuming time idle period, help to reduce data and write fashionable employed expense in system.
Wherein, before the described blank block that obtains writes data, check whether the described blank block that obtains is bad piece,, then behind the bad piece of mark, from described unordered formation, obtain next piece blank block if assay is a bad piece;
If assay is not a bad piece, then write data to the described blank block that obtains.
Wherein, can be after the described blank block that obtains write data, the modified address mapping table.
Wherein, can be after the mapping table of modified address, by described address mapping table, reading of data.
The executive agent of embodiment of the invention method can be a memory device, specifically can be hard disk, more specifically can be solid state hard disc.Described solid state hard disc can be single flash chip, a plurality of flash chip, flash array or ROM (read-only memory) etc.
Pass through the embodiment of the invention, can obtain identical or the corresponding techniques effect: by the phase is checked grouping information table and erasable count table at one's leisure with aforementioned each embodiment, judge whether need to trigger the wear leveling strategy, overcome the excessive technical matters of system overhead that data write operation is tested and caused period; When judgement needs to trigger the wear leveling strategy, just the blank block that reclaims is inserted unordered formation, use described blank block to write data during for data write operation, thereby carry out the big blank block recovery operation of amount consuming time idle period, help to reduce data and write fashionable employed expense in system.
As shown in Figure 4, be embodiments of the invention two, can comprise step:
401, when system's free time or blank block quantity are less than predetermined number, reclaim blank block, when reclaiming blank block, can also carry out the bad block check line correlation record of going forward side by side;
402, phase at one's leisure by check grouping information table and erasable count table, obtains the erasable number of times of every group of information and data block, and judging whether needs to trigger the wear leveling strategy, if judged result is for being that then execution in step 403; If judged result is that then execution in step 401, continues to prepare to trigger the wear leveling strategy next time and judge;
403, trigger the wear leveling strategy, then the blank block that reclaims is inserted unordered formation, for upcoming data write operation is prepared.
404, during data write operation, select blank block from unordered formation, allocation space writes data;
In practice, can also before writing data, carry out bad block check to blank block, occur if any bad piece, then behind the bad piece of mark, from unordered formation, distribute next blank block in turn, be used for data write operation.
405, after data write operation is finished, the physical address of the data in the mapping table of modified address and the mapping relations of logical address.
In practice,, then can directly pass through the logical address reading of data of data if carry out data reading operation.
Embodiment of the invention method can be adjusted each sequence of steps according to actual needs.
The executive agent of embodiment of the invention method can be a memory device, specifically can be hard disk, more specifically can be solid state hard disc.Described solid state hard disc can be single flash chip, a plurality of flash chip, flash array or ROM (read-only memory) etc.
With reference to shown in Figure 5, the described wear leveling strategy of the embodiment of the invention can comprise that group is outer balanced, is example with the flash chip:
According to physical address the storage medium stores zone is divided into the N group: 1,2 ..., N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, be less than preset value T1 if be used for the quantity of the blank block that the unordered formation of blank block storage stores, obtain the blank block of respectively organizing erasable number of times minimum in the described N group, the described blank block of respectively organizing erasable number of times minimum that obtains is inserted described unordered formation.
In Fig. 5, the value of T1 can be made as 5%, in practice, can also be set to other values.Outer balanced by organizing, the blank block of erasable number of times minimum in each group can be distributed to data write operation.
With reference to shown in Figure 6, the described wear leveling strategy of the embodiment of the invention can comprise between group balanced:
According to physical address the storage medium stores zone is divided into the N group: 1,2 ..., N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, if a group does not comprise blank block, with the described group that does not comprise blank block as first group, then will comprise blank block any one group as second group;
Determine the average erasable number of times of described first group and second group;
Determine the ratio of described first group of average erasable number of times and second group of average erasable number of times, if described ratio more than or equal to preset value T2, then carries out exchanges data between described first group and second group.The group in exchanges data to as if all valid data.
By equilibrium between organizing, make that the quantity of the blank block between each group is approaching relatively, the erasable number of times difference of data is excessive between being unlikely to respectively to organize, and has kept between group balanced.The value of T2 can be made as 130%, in practice, can also be set to other values.
With reference to shown in Figure 7, the described wear leveling strategy of the embodiment of the invention can comprise in the group balanced:
According to physical address the storage medium stores zone is divided into the N group: 1,2 ..., N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, obtain every group in the maximum erasable number of times and the minimum erasable number of times of all pieces;
If the difference of erasable number of times of described maximum and minimum erasable number of times more than or equal to preset value T3, is then carried out exchanges data between the data block with erasable number of times of described maximum and minimum erasable number of times.
By organizing interior equilibrium, allow the few data block of erasable number of times receive new data write operation, make that the erasable number of times between interior each data block of group is approaching, the serviceable life of having improved chip.The value of T3 can specifically be provided with in practice.
Balanced and the outer equilibrium of group can separately exist between balanced in above-mentioned group, group, can select one realize or this three between combination in any, can both obtain and organize between interior equilibrium, group balanced corresponding techniques effect outside the balanced and group.If occur two or more balance policies simultaneously, then its technique effect also can correspondingly superpose.Outer balanced by organizing, the blank block of erasable number of times minimum in each group can be distributed to data write operation.By equilibrium between organizing, make that the quantity of the blank block between each group is approaching relatively, the erasable number of times difference of data is excessive between being unlikely to respectively to organize, and has kept between group balanced.By organizing interior equilibrium, allow the few data block of erasable number of times receive new data write operation, make that the erasable number of times between interior each data block of group is approaching, the serviceable life of having improved chip.
As shown in Figure 8, be the state exchange synoptic diagram of the embodiment of the invention, direction shown in the arrow is from a previous state state exchange backward.
As shown in Figure 9, be embodiments of the invention three, present embodiment provides a kind of hard disk, comprising:
Inspection unit 901 is used for the phase at one's leisure, checks grouping information table and erasable count table, judges whether to need to trigger the wear leveling strategy;
Insert unit 902, be used for triggering if desired the wear leveling strategy, then the blank block that reclaims is inserted unordered formation;
Writing unit 903 is used for obtaining blank block in data write operation period from described unordered formation, writes data to the described blank block that obtains.
The hard disk of the embodiment of the invention can be solid state hard disc etc.Described solid state hard disc can be single flash chip, a plurality of flash chip, flash array or ROM (read-only memory) etc.
Each unit of the embodiment of the invention can be integrated in one, and also can separate deployment.Said units can be merged into a unit, also can further split into a plurality of subelements.
Utilize the embodiment of the invention, by check grouping information table of phase at one's leisure and erasable count table, judging whether needs to trigger the wear leveling strategy, has overcome the excessive technical matters of system overhead that data write operation is tested and caused period; When judgement needs to trigger the wear leveling strategy, just the blank block that reclaims is inserted unordered formation, use described blank block to write data during for data write operation, thereby carry out the big blank block recovery operation of amount consuming time idle period, help to reduce data and write fashionable employed expense in system.
Wherein, with reference to shown in Figure 10, be the embodiment of the invention four, on the basis of embodiment three, the hard disk of the embodiment of the invention can also comprise:
Reclaim unit 1001, be used for before checking grouping information table and erasable count table, reclaiming blank block.
Wherein, can also comprise:
The first bad piece inspection unit 1002 is used for when reclaiming blank block, and the blank block that described recovery is obtained carries out bad block check record.
Wherein, can also comprise:
The second bad piece inspection unit 1003 is used for before the described blank block that obtains writes data, checks whether the described blank block that obtains is bad piece;
Acquiring unit 1004 is a bad piece if be used for assay, then behind the bad piece of mark, obtains next piece blank block from described unordered formation;
Second writing unit 1005 is not a bad piece if be used for assay, then writes data to the described blank block that obtains.
Wherein, can also comprise:
Revise unit 1006, be used for after the described blank block that obtains writes data the modified address mapping table.
Wherein, be example with the flash chip, described wear leveling strategy can comprise:
According to physical address the storage medium stores zone is divided into the N group: 1,2 ..., N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, be less than preset value T1 if be used for the quantity of the blank block that the unordered formation of blank block storage stores, obtain the blank block of respectively organizing erasable number of times minimum in the described N group, the described blank block of respectively organizing erasable number of times minimum that obtains is inserted described unordered formation.
Perhaps, wherein, described wear leveling strategy can comprise:
According to physical address the storage medium stores zone is divided into the N group: 1,2 ..., N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, if a group does not comprise blank block, with the described group that does not comprise blank block as first group, then will comprise blank block any one group as second group;
Calculate the average erasable number of times of described first group and second group;
Calculate the ratio of described first group of average erasable number of times and second group of average erasable number of times, if described ratio more than or equal to preset value T2, then carries out exchanges data between described first group and second group.
Perhaps, wherein, described wear leveling strategy can comprise:
According to physical address storage medium stores area dividing (can be even division) is the N group: 1,2......, N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, obtain every group in the maximum erasable number of times and the minimum erasable number of times of all pieces;
If the difference of erasable number of times of described maximum and minimum erasable number of times more than or equal to preset value T3, is then carried out exchanges data between the data block with erasable number of times of described maximum and minimum erasable number of times.
Balanced and the outer equilibrium of group can separately exist between balanced in above-mentioned group, group, can select one realize or this three between combination in any, can both obtain and organize between interior equilibrium, group balanced corresponding techniques effect outside the balanced and group.If occur two or more balance policies simultaneously, then its technique effect also can correspondingly superpose.
Outer balanced by organizing, the blank block of erasable number of times minimum in each group can be distributed to data write operation.By equilibrium between organizing, make that the quantity of the blank block between each group is approaching relatively, the erasable number of times difference of data is excessive between being unlikely to respectively to organize, and has kept between group balanced.By organizing interior equilibrium, allow the few data block of erasable number of times receive new data write operation, make that the erasable number of times between interior each data block of group is approaching, the serviceable life of having improved chip.
Each module of embodiment of the invention equipment can be integrated in one, and also can separate deployment.Above-mentioned module can be merged into a module, also can further split into a plurality of submodules.
Wherein, described solid state hard disc can be single flash chip, a plurality of flash chip, flash array or ROM (read-only memory) etc.
Technical scheme by the utilization embodiment of the invention in the middle of single flash chip, a plurality of flash chip, flash array or ROM (read-only memory) etc., can obtain identical or the corresponding techniques effect: by the phase is checked grouping information table and erasable count table at one's leisure with aforementioned each embodiment, judge whether need to trigger the wear leveling strategy, overcome the excessive technical matters of system overhead that data write operation is tested and caused period; When judgement needs to trigger the wear leveling strategy, just the blank block that reclaims is inserted unordered formation, use described blank block to write data during for data write operation, thereby carry out the big blank block recovery operation of amount consuming time idle period, help to reduce data and write fashionable employed expense in system.
As shown in figure 11, be the system that the embodiment of the invention five is provided, comprise input-output device 1101 and hard disk 1102, wherein:
Described input-output device 1101 is used for to hard disk input data, from the hard disk output data;
Described hard disk 1102 is used for the phase at one's leisure, checks grouping information table and erasable count table, judges whether to need to trigger the wear leveling strategy; Trigger the wear leveling strategy if desired, then the blank block that reclaims is inserted unordered formation;
In data write operation period, from described unordered formation, obtain blank block, write data to the described blank block that obtains.
The hard disk of the embodiment of the invention can be solid state hard disc etc.Described solid state hard disc can be single flash chip, a plurality of flash chip, flash array or ROM (read-only memory) etc.
Each unit of embodiment of the invention system can be integrated in a device, also can be distributed in multiple arrangement.Said units can be merged into a unit, also can further split into a plurality of subelements.
Utilize the embodiment of the invention, by check grouping information table of phase at one's leisure and erasable count table, judging whether needs to trigger the wear leveling strategy, has overcome the excessive technical matters of hard-disk system expense that data write operation is tested and caused period; When judgement needs to trigger the wear leveling strategy, just the blank block that reclaims is inserted unordered formation, use described blank block to write data during for data write operation, thereby carry out the big blank block recovery operation of amount consuming time idle period in hard-disk system, help to reduce data and write fashionable employed expense.Because the expense of hard-disk system descends, can correspondingly promote the work efficiency of the entire system at hard disk place.
Wherein, described hard disk can be single flash chip, a plurality of flash chip, flash array or ROM (read-only memory) etc.
Wherein, be example with the flash chip, described wear leveling strategy can comprise:
According to physical address the storage medium stores zone is divided into the N group: 1,2 ..., N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, be less than preset value T1 if be used for the quantity of the blank block that the unordered formation of blank block storage stores, obtain the blank block of respectively organizing erasable number of times minimum in the described N group, the described blank block of respectively organizing erasable number of times minimum that obtains is inserted described unordered formation.
Perhaps, wherein, described wear leveling strategy can comprise:
According to physical address the storage medium stores zone is divided into the N group: 1,2......N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, if a group does not comprise blank block, with the described group that does not comprise blank block as first group, then will comprise blank block any one group as second group;
Calculate the average erasable number of times of described first group and second group;
Calculate the ratio of described first group of average erasable number of times and second group of average erasable number of times, if described ratio more than or equal to preset value T2, then carries out exchanges data between described first group and second group.
Perhaps, wherein, described wear leveling strategy can comprise:
According to physical address the storage medium stores zone is divided into the N group: 1,2......N, every group of A blocks of data piece, N is more than or equal to 2, and A is more than or equal to 2;
Phase at one's leisure, obtain every group in the maximum erasable number of times and the minimum erasable number of times of all pieces;
If the difference of erasable number of times of described maximum and minimum erasable number of times more than or equal to preset value T3, is then carried out exchanges data between the data block with erasable number of times of described maximum and minimum erasable number of times.
Balanced and the outer equilibrium of group can separately exist between balanced in above-mentioned group, group, can select one realize or this three between combination in any, can both obtain and organize between interior equilibrium, group balanced corresponding techniques effect outside the balanced and group.If occur two or more balance policies simultaneously, then its technique effect also can correspondingly superpose.
Outer balanced by organizing, the blank block of erasable number of times minimum in each group can be distributed to data write operation.By equilibrium between organizing, make that the quantity of the blank block between each group is approaching relatively, the erasable number of times difference of data is excessive between being unlikely to respectively to organize, and has kept between group balanced.By organizing interior equilibrium, allow the few data block of erasable number of times receive new data write operation, make that the erasable number of times between interior each data block of group is approaching, the serviceable life of having improved chip.
Through the above description of the embodiments, the those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential general hardware platform, can certainly pass through hardware, but the former is better embodiment under a lot of situation.Technical scheme of the present invention can embody with the form of software product, this computer software product can be stored in the storage medium, comprise that some instructions are with so that computer equipment (can be a personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
Above-described embodiment of the present invention does not constitute the qualification to protection domain of the present invention.Any modification of being done within the spirit and principles in the present invention, be equal to and replace and improvement etc., all should be included within protection scope of the present invention.