Summary of the invention
The present invention provides a kind of block management method, and it can use the flash memory physical blocks fifty-fifty, and then prolongs its serviceable life effectively.
The present invention provides a kind of flash memory storage system, and it uses above-mentioned block management method to come to use fifty-fifty its flash memory physical blocks, and then prolongs its serviceable life effectively.
The present invention provides a kind of flash memory control, and it uses above-mentioned block management method to come to use fifty-fifty the flash memory physical blocks, and then serviceable life extended period effectively.
The present invention proposes a kind of block management method, is used to manage a plurality of flash memory physical blocks.This block management method comprises the flash memory physical blocks is grouped into a plurality of solid elements (physicalunit), and with solid element logically be grouped into a data field (data area), a spare area (sparearea) replaces district (replace area) with one.This block management method is also included within and carries out the exchange of one first solid element between data field and the spare area; And in the spare area and replace and to carry out the exchange of one second solid element between the district, wherein the exchange of second solid element be in order to exchange the spare area with replace good solid element (good physical unit) in the district.
In one embodiment of this invention, the step of above-mentioned execution first solid element exchange comprises: select one first solid element among being subordinated to the solid element of above-mentioned data field; Select one second solid element among being subordinated to the solid element of above-mentioned spare area; The data of being stored in first solid element are copied in second solid element; First solid element is associated as belongs to above-mentioned spare area; And second solid element is associated as belongs to above-mentioned data field.
In one embodiment of this invention, above-mentioned in the spare area and replace and to carry out the exchange of second solid element between the district and comprise: as when above-mentioned solid element is carried out an erasing instruction, to count an erasing instruction and carry out number of times; And when this erasing instruction is carried out number of times greater than a replacement district average abrasion startup value, then carry out above-mentioned second solid element exchange.
In one embodiment of this invention, above-mentioned in the spare area and replace and to carry out the exchange of second solid element between the district and comprise: record belongs to the one first average erasing times of solid element of solid element and the above-mentioned spare area of above-mentioned data field; Record belongs to one second average erasing times of the solid element in above-mentioned replacement district; And, then carry out above-mentioned second solid element exchange when this first average erasing times when a difference value of the second average erasing times is greater than a difference threshold value therewith.
In one embodiment of this invention, above-mentioned in the spare area and replace and to carry out the exchange of second solid element between the district and comprise: record belongs to one the 3rd average erasing times of the solid element of above-mentioned spare area; Record belongs to the equal erasing times in a Siping City of the solid element in above-mentioned replacement district; And, then carry out above-mentioned second solid element exchange when this 3rd average erasing times when a difference value of the equal erasing times in Siping City is greater than a difference threshold value therewith.
In one embodiment of this invention, the step of above-mentioned execution second solid element exchange comprises: select one the 3rd solid element among being subordinated to the solid element of above-mentioned spare area; Select one the 4th solid element among being subordinated to the solid element in above-mentioned replacement district; This 3rd solid element is associated as belongs to above-mentioned replacement district; And this 4th solid element is associated as belongs to above-mentioned spare area.
In one embodiment of this invention, above-mentioned block management method also comprises safeguards that one replaces the solid element table, wherein writes down the solid element that belongs to above-mentioned replacement district in this replacement solid element table.
In one embodiment of this invention, above-mentioned block management method also comprises: an erasing times that writes down each solid element; And divide into a high scratching area and a low scratching area, and select above-mentioned the 3rd solid element in the from then on high scratching area according to the physical blocks that the erasing times that is write down will belong to above-mentioned spare area.
The present invention proposes a kind of flash memory control; Be used to manage a plurality of flash memory physical blocks of a flash memory storage system; Flash memory interface module, host interface module, memory buffer and memory management module that this flash memory control comprises microprocessor unit and couples this microprocessing unit; Wherein memory management module is grouped into these flash memory physical blocks a plurality of solid elements and the solid element that is divided into groups logically is grouped into a data field, a spare area and a replacement district; Wherein memory management module can be carried out the exchange of one first solid element between data field and spare area; And in the spare area and replace and to carry out the exchange of one second solid element between the district, wherein this second solid element exchange be in order to exchange the spare area with replace good solid element in the district.
In one embodiment of this invention, above-mentioned memory management module is carried out the exchange of second solid element and is comprised the steps: when above-mentioned solid element is carried out an erasing instruction, count an erasing instruction and carry out number of times; And when this erasing instruction is carried out number of times greater than a replacement district average abrasion startup value, then carry out above-mentioned second solid element exchange.
In one embodiment of this invention, above-mentioned memory management module is carried out this second solid element exchange and comprised the steps: record belongs to the one first average erasing times of solid element of solid element and the above-mentioned spare area of above-mentioned data field; Record belongs to one second average erasing times of the solid element in above-mentioned replacement district; And, then carry out above-mentioned second solid element exchange when this first average erasing times when a difference value of the second average erasing times is greater than a difference threshold value therewith.
In one embodiment of this invention, above-mentioned in the spare area and replace and to carry out the exchange of second solid element between the district and comprise: record belongs to one the 3rd average erasing times of the solid element of above-mentioned spare area; Record belongs to the equal erasing times in a Siping City of the solid element in above-mentioned replacement district; And, then carry out above-mentioned second solid element exchange when this 3rd average erasing times when a difference value of the equal erasing times in Siping City is greater than a difference threshold value therewith.
In one embodiment of this invention, above-mentioned memory management module is carried out the exchange of second solid element and is comprised the steps: select one the 3rd solid element among being subordinated to the solid element of above-mentioned spare area; Select one the 4th solid element among being subordinated to the solid element in above-mentioned replacement district; This 3rd solid element is associated as belongs to above-mentioned replacement district; And this 4th solid element is associated as belongs to above-mentioned spare area.
In one embodiment of this invention; One erasing times of above-mentioned each solid element of MMU record; And the physical blocks that will belong to above-mentioned spare area according to the erasing times that is write down is divided into a high scratching area and a low scratching area, and wherein MMU can be selected above-mentioned the 3rd solid element from high scratching area.
The present invention proposes a kind of flash memory storage system; It comprises flash memory chip, connector and the flash memory control with a plurality of flash memory physical blocks, and wherein flash memory control is to electrically connect so far flash memory chip connector therewith.In this flash memory storage system; Flash memory control can be grouped into these flash memory physical blocks a plurality of solid elements and the solid element that is divided into groups logically is grouped into a data field, a spare area and a replacement district; Wherein flash memory control can be carried out the exchange of one first solid element between data field and spare area; And in the spare area and replace and to carry out the exchange of one second solid element between the district, wherein the exchange of second solid element be in order to exchange the spare area with replace good solid element in the district.
In one embodiment of this invention, above-mentioned flash memory control is carried out above-mentioned second solid element exchange and is comprised the steps: when above-mentioned solid element is carried out an erasing instruction, count an erasing instruction and carry out number of times; And when this erasing instruction is carried out number of times greater than a replacement district average abrasion startup value, then carry out above-mentioned second solid element exchange.
In one embodiment of the invention, above-mentioned flash memory control is carried out the exchange of above-mentioned second solid element and comprised the steps: record belongs to the one first average erasing times of solid element of solid element and the above-mentioned spare area of above-mentioned data field; Record belongs to one second average erasing times of the solid element in above-mentioned replacement district; And, then carry out above-mentioned second solid element exchange when this first average erasing times when a difference value of the second average erasing times is greater than a difference threshold value therewith.
In one embodiment of the invention, the number of physical blocks that belongs to above-mentioned replacement district is greater than 2000.
In one embodiment of the invention, above-mentioned flash memory chip comprises at least 4 flash memory module.
Based on above-mentioned, the present invention is because of in data field and spare area and in the spare area and replace and carry out the solid element exchange between the district, therefore can the average data district, the wearing and tearing of spare area and the physical blocks in replacement district, and then the life-span of prolongation flash memory storage system.
For letting the above-mentioned feature and advantage of the present invention can be more obviously understandable, hereinafter is special lifts embodiment, and conjunction with figs. elaborates as follows.
Embodiment
Fig. 1 is the summary calcspar of the flash memory storage system that one exemplary embodiment is illustrated according to the present invention.
Please with reference to Fig. 1, flash memory storage system 100 can use with main frame 200 usually, so that host computer system 200 can write to flash memory storage system 100 or reading of data from flash memory storage system 100 with data.In the present embodiment, flash memory storage system 100 be solid state hard disc (Solid State Drive, SSD).But it must be appreciated that flash memory storage system 100 also can be storage card or coil with oneself in another embodiment of the present invention.
Flash memory storage system 100 comprises connector 120, flash memory control 110 and flash memory chip 130.
A plurality of logic gates or mechanical order that flash memory control 110 can be carried out with hardware pattern or the real work of firmware pattern carry out the runnings such as writing, read and wipe of data with matching connector 120 and flash memory chip 130.Flash memory control 110 comprises microprocessor unit 110a, memory management module 110b, flash memory interface module 110c, memory buffer 110d and host interface module 110e.
Microprocessor unit 110a in order to cooperative cooperatings such as memory management module 110b, flash memory interface module 110c, memory buffer 110d and host interface module 110e to carry out the various runnings of flash memory storage system 100.
Memory management module 110b is coupled to microprocessor unit 110a.Memory management module 110b is in order to carry out the block management mechanism according to this exemplary embodiment.
In the present embodiment; Memory management module 110b is embodied in the controller 110 with a firmware pattern; For example write the associated mechanical instruction and be stored in program storage (for example, the next real memory management module 110b that does of ROM (read-only memory) (Read Only Memory, ROM)) with program language.When flash memory storage system 100 runnings; A plurality of machine instructions of memory management module 110b can be loaded among the memory buffer 110d indirectly, and are carried out or directly carried out to accomplish the block management mechanism according to the embodiment of the invention by microprocessor unit 110a by microprocessor unit 110a.
In another embodiment of the present invention, the mechanical order of memory management module 110b also can the software pattern be stored in the specific region (for example, being exclusively used in the system region of storage system data in the flash memory) of flash memory chip 130.Same, when flash memory storage system 100 runnings, a plurality of machine instructions of memory management module 110b can be loaded among the memory buffer 110d and by microprocessor unit 110a to be carried out.In addition, in another embodiment of the present invention, memory management module 110b also can a hardware pattern be embodied in the controller 110.
Flash memory interface module 110c is coupled to microprocessor unit 110a and in order to access flash memory chip 130.Just, the data of desiring to write to flash memory chip 130 can convert 130 receptible forms of flash memory chip into via flash memory interface module 110c.
Memory buffer 110d is coupled to microprocessor unit 110a and in order to temporarily memory system data (for example logical address-physical address mapping table) or 200 data that read or write of host computer system.In the present embodiment, memory buffer 110d be static RAM (static randomaccess memory, SRAM).Yet; It must be appreciated; The invention is not restricted to this, and dynamic RAM (Dynamic Random Access memory, DRAM), reluctance type storer (Magnetoresistive Random Access Memory; MRAM), phase transition storage (PhaseChange Random Access Memory, PRAM) or other storeies that are fit to also can be applicable to the present invention.
Host interface module 110e is the instruction that is coupled to microprocessor unit 110a and is transmitted in order to reception and identification host computer system 200.Just, the instruction and the data that are transmitted of host computer system 200 can be sent to microprocessor unit 110a through host interface module 110e.In the present embodiment, host interface module 110e is the SATA interface.Yet; It must be appreciated to the invention is not restricted to this that host interface module 110e also can be USB interface, IEEE 1394 interfaces, PCI Express interface, MS interface, MMC interface, SD interface, CF interface, ide interface or other data transmission interfaces that is fit to.Particularly, host interface module 110e can be corresponding with connector 120.Just, host interface module 110e must arrange in pairs or groups mutually with connector 120.
In addition, though be not illustrated in present embodiment, controller 110 can comprise also that error correction module and power management module etc. are used to control the general utility functions module of flash memory.
Connector 120 is in order to connect host computer system 200 through bus 300.In the present embodiment, connector 120 is the SATA connector.Yet; It must be appreciated to the invention is not restricted to this that connector 120 also can be USB connector, IEEE 1394 connectors, PCI Express connector, MS connector, MMC connector, SD connector, CF connector, IDE connector or other connectors that is fit to.
Flash memory chip 130 be electrically connected to flash memory control 110 and in order to the storage data.Flash memory chip 130 is multilayer memory cell (Multi Level Cell, MLC) a NAND flash memory in this enforcement.Yet, it must be appreciated, the invention is not restricted to this.In another embodiment of the present invention, (Single Level Cell, SLC) the NAND flash memory also can be applicable to the present invention to the individual layer memory cell.
Fig. 2 is the summary calcspar of the flash memory chip that one exemplary embodiment is illustrated according to the present invention.
In this exemplary embodiment; Flash memory chip 130 comprises first flash memory module 210, second flash memory module 220, the 3rd flash memory module 230 and the 4th flash memory module 240, and wherein first flash memory module 210 has physical blocks 210-(0)~210-(N); Second flash memory module 220 has physical blocks 220-(0)~220-(N); The 3rd flash memory module 230 has physical blocks 230-(0)~230-(N); And the 4th flash memory module 240 have physical blocks 240-(0)~240-(N).What deserves to be mentioned is,, yet the invention is not restricted to this though exemplary embodiment of the present invention is to describe with the flash memory chip 130 that comprises 4 flash memory module.Particularly, have 4 or more how soon the flash memory chip of flash memory module be more suitable for using the block management mechanism of exemplary embodiment of the present invention to manage.
Physical blocks is the least unit of wiping in flash memory chip 130.That is each physical blocks contains the memory cell that is wiped free of in the lump of minimal amount.Each physical blocks can be divided into several pages (page) usually.The page is generally the minimum unit of sequencing (program).But what specify is in some different flash memory design, and minimum sequencing unit also can be a sector (sector).That is to say the minimum unit that in page a plurality of sectors is arranged and be sequencing with a sector.In other words, the page is the minimum unit that writes data or reading of data.Each page generally includes user data field D and redundant area R.The user data field is in order to storage user's data, and redundant area is in order to data (for example, the bug check and the correcting code (Error Checking andCorrecting Code, ECC Code) of storage system.
Be sector (sector) size corresponding to disc driver, generally speaking, user data field D is generally 512 bytes, and redundant area R is generally 16 bytes.Just, a page address is a sector.Yet, also can form a page address in a plurality of sectors.In this exemplary embodiment, each page is to comprise 4 sectors.
Generally speaking, physical blocks can be made up of the page of arbitrary number, for example 64 pages, 128 pages, 256 pages etc.In addition; The physical blocks of first flash memory module 210, second flash memory module 220, the 3rd flash memory module 230 and the 4th flash memory module 240 also can be grouped into several zones (zone) usually, comes management entity block 210-(0)~210-(N), physical blocks 220-(0)~220-(N), physical blocks 230-(0)~230-(N) and physical blocks 240-(0)~240-(N) can increase the parallel degree that operation carries out and the complexity of streamlining management with each distinct area.
In addition; Flash memory control 110 can logically be grouped into a plurality of solid elements with the physical blocks in first flash memory module 210, second flash memory module 220, the 3rd flash memory module 230 and the 4th flash memory module 240 and manage, and for example 1 solid element comprises 4 physical blocks.Because when managing with solid element, flash memory control 110 is to come service logic address-physical address mapping table with bigger unit (being solid element), therefore can save the space of the memory buffer 110d of required use.In exemplary embodiment of the present invention, physical blocks 210-(0)~210-(N), physical blocks 220-(0)~220-(N), physical blocks 230-(0)~230-(N) can logically be grouped into solid element 310-(0)~310-(N) with physical blocks 240-(0)~240-(N).
Fig. 3 A~Fig. 3 C is the running synoptic diagram that one exemplary embodiment illustrates flash memory chip according to the present invention.
It must be appreciated; When this describes the running of flash memory physical blocks, with " extraction ", " moving ", " exchange ", " replacement ", " rotating ", " cut apart ", " division " and etc. speech to come the physical blocks of operating flash memory chips 130 are notions in logic.That is to say that the physical location of the physical blocks of flash memory is not changed, but in logic the physical blocks of flash memory is operated.What deserves to be mentioned is that following running is that the memory management module 110b by flash memory control 110 accomplishes.
Please with reference to Fig. 3 A; Memory management module 110b can logically be grouped into solid element 310-(0)~310-(N) with the physical blocks of flash memory chip 130, and can solid element 310-(0)~310-(N) logically is grouped into memory block 320 and replace district 330.
Solid element 310-(0) in memory block 320~310-(P) is the solid element that normally is used in the flash memory storage system 100.That is to say that memory management module 110b can write to the solid element that belongs to memory block 320 with data.
Please with reference to Fig. 3 B, memory management module 110b can logically be grouped into the physical blocks of memory block 320 system region 302, a data field 304 and a spare area 306.
System region 302 comprises solid element 310-(0)~solid element 310-(S), and data field 304 comprises solid element 310-(S+1)~solid element 310-(S+M), and spare area 306 comprises solid element 310-(S+M+1)~solid element 310-(P).In the present embodiment, above-mentioned S, M and P are positive integer, the physical blocks quantity of each district's configuration of its representative, and it can be set according to the capacity of employed flash memory module by the manufacturer of flash memory storage system.
Belong to solid element in the system region 302 in logic in order to the register system data, this system data comprises about the manufacturer of flash memory chip and model, the number of regions of each flash memory module, the physical blocks number that each is regional, page number of each physical blocks etc.
Belonging to solid element in the data field 304 in logic in order to storage user's data, in general is exactly the solid element that the logical block of 200 accesses of host computer system is shone upon.That is to say that the solid element of data field 304 is the unit of storage valid data.
Therefore the solid element that belongs in logic in the spare area 306 is in order to the solid element in the data field 304 of rotating, and the solid element in spare area 306 be sky or spendable unit, i.e. no record data or be labeled as invalid data useless.That is to say the data that the solid element of data field 304 and spare area 306 can come 200 pairs of flash memory storage systems 100 of host system to write with the mode of rotating.
As previously mentioned; The solid element of flash memory chip 130 can provide host computer system 200 to store data with the mode of rotating; Therefore memory management module 110b can provide logical block 350-1~350-M to host computer system 200 carrying out data access, and write down the solid element that logical block is shone upon through service logic address-physical address mapping table (1ogical address-physical address mapping table).
Please be simultaneously with reference to Fig. 3 B and Fig. 3 C; For example; When host computer system desired to write data to logical block 350-1, memory management module 110b can learn that logical block 350-1 is the solid element 310-(S+1) that belongs to data field 304 on the mapping logic at present through logical address-physical address mapping table.Therefore, memory management module 110b can upgrade the data among the solid element 310-(S+1), during, flash memory control 110 can extract the rotate solid element 310-(S+1) of data field 304 of solid element 310-(S+M+1) from spare area 306.Yet; When memory management module 110b write to solid element 310-(S+M+1) with new data, memory management module 110b can not move all valid data among the solid element 310-(S+1) to solid element 310-(S+M+1) at once and wipe solid element 310-(S+1).Specifically; Memory management module 110b can write page valid data before (promptly with desiring among the solid element 310-(S+1); Page or leaf P0 and P1) be copied to solid element 310-(S+M+1) (like (a) of Fig. 3 C); And (that is, page or leaf P2 and the P3 of solid element 310-(S+M+1)) writes to solid element 310-(S+M+1) (like (b) of Fig. 3 C) with new data.At this moment, memory management module 110b promptly accomplishes the action that writes.Because the valid data among the solid element 310-(S+1) might be in next operation (for example; Write instruction) in become invalidly, therefore at once all valid data among the solid element 310-(S+1) are moved to replacement solid element 310-(S+M+1) and may be caused meaningless moving.In this case, the content integration of solid element 310-(S+1) and solid element 310-(S+M+1) gets up to be only the complete content of the mapping logic unit 350-1 of institute.These mother-child relationship (MCR)s (promptly; Solid element 310-(S+1) and solid element 310-(S+M+1)) the transient state relation can decide according to the size of memory buffer 110d in the flash memory control 110, be commonly referred to as unlatching (open) mother and child blocks and temporarily keep the action that this kind transient state concerns.For example, in the present embodiment, memory management module 110b can open five groups of mother and child blocks simultaneously at most.
Afterwards; In the time need the content of solid element 310-(S+1) and solid element 310-(S+M+1) really being merged; Memory management module 110b is just can be with solid element 310-(S+1) and solid element 310-(S+M+1) whole and be a solid element; Promote the service efficiency of block thus, the action of this merging can be described as again closes (close) mother and child blocks.For example; Shown in Fig. 3 C (c), when closing mother and child blocks, memory management module 110b can be with remaining valid data among the solid element 310-(S+1) (promptly; Page or leaf P4~PN) is copied to replacement solid element 310-(S+M+1); Then solid element 310-(S+1) is wiped and be associated as spare area 306, simultaneously, solid element 310-(S+M+1) is associated as data field 304; And the mapping with logical block 350-1 in logical address-physical address mapping table changes to solid element 310-(S+M+1), accomplishes the action of closing mother and child blocks thus.
In general, be called the transaction unit through the solid element of rotating between data field 304 and the spare area 306 of being everlasting.In addition, in data field 304, often having some data to write the back did not just change for a long time.For example,, the user just never goes deletion or upgrade after storing the MP3 song that 100 head like again.The solid element of storing these type of data is commonly referred to as the static entities unit.The static entities unit is owing to seldom change or upgrade, so its erasing times can low relatively (that is, the degree of wear be lower).In the present invention implements; Memory management module 110b can carry out the action of solid element exchange between data field 304 and spare area 306; So that less solid element of rotating has an opportunity to rotate in the data field 304, the wearing and tearing of average physical blocks effectively thus.
Fig. 4 is the process flow diagram of one exemplary embodiment illustrate performed solid element exchange between data field 304 and spare area 306 according to the present invention.
Please with reference to Fig. 4, when flash memory storage system 100 starts, at first memory management module 110b can setting data district's average abrasion startup value in step S401.Data field average abrasion startup value is to represent the frequency of the solid element exchange between log-on data district 304 and the spare area 306; Wherein data field average abrasion startup value is bigger; The frequency that starts the solid element exchange is lower; Otherwise data field average abrasion startup value is littler, and the frequency that starts the solid element exchange is higher.User (for example, the manufacturer of storage system) can be according to the quality of employed flash memory and the effect of desiring to reach average abrasion come setting data district average abrasion startup value voluntarily.Be noted that the effect of the higher then average abrasion of frequency of carrying out the solid element exchange is better, but the time of carrying out the solid element clearing house and needing can influence the usefulness of flash memory storage system 100.Data field average abrasion startup value is to be set at 500 in this exemplary embodiment.
In step S403, flash memory control 110 can be awaited orders and when arbitrary solid element was wiped free of, memory management module 110b can count first erasing instruction and carry out number of times.For example, memory management module 110b can add 1 with first erasing instruction execution number of times.
Afterwards, memory management module 110b can judge that whether first erasing instruction execution number of times is greater than data field average abrasion startup value in step S405.If in step S405, judge and then in step S407, can carry out the solid element exchange when first erasing instruction is carried out number of times greater than data field average abrasion startup value.Specifically; Memory management module 110b can extract a solid element (S407-1) randomly among the solid element that belongs to data field 304 in logic in step S407; And among the solid element that belongs to spare area 306 in logic, extract a solid element (S407-3) randomly, the data in the solid element that will from data field 304, be extracted then are copied in the solid element that from spare area 306, is extracted (S407-5).The solid element that will from spare area 306, be extracted at last, is associated as data field 304 (S407-7) and the solid element that will from data field 304, be extracted is associated as spare area 306 (S407-9) after wiping.That is to say; After execution in step S407-7 and S409-9; The solid element that from spare area 306, is extracted can logically belong to data field 304; And the solid element that from data field 304, is extracted can logically belong to spare area 306, accomplishes the solid element exchange between data field 304 and the spare area 306 thus.
For example, if when carrying out the physical blocks exchange, from data field 304, extract solid element 310-(S+M), and from spare area 306, extract solid element 310-(P), wherein solid element 310-(S+M) is mapping logic unit 350-M.Then; Data among the solid element 310-(S+M) can be copied among the solid element 310-(P); Solid element 310-(S+M) can be wiped free of and be associated as spare area 306; And solid element 310-(P) can be associated as data field 304, and wherein logical address-physical address mapping table can be updated to logical block 350-M mapping solid element 310-(P).
What deserves to be mentioned is, be from data field 304 and spare area 306, to select the solid element that exchanges with at random mode in this exemplary embodiment.Yet; In another exemplary embodiment of the present invention; Memory management module 110b also can write down the erasing times of each solid element, and be chosen in erasing times is lower in the data field 304 solid element and in spare area 306 the higher solid element of erasing times exchange.That is to say that the solid element in the spare area 306 can be divided into height and wipe solid element and the low solid element of wiping, the wherein high solid element of wiping can be used as the solid element that carries out the solid element exchange.For example; Height in the spare area 306 is wiped solid element and is meant that erasing times is higher than the solid element of the erasing times mean value of all solid elements in the spare area 306, and the low solid element of wiping is meant that in spare area 306 erasing times is lower than the solid element of the erasing times mean value of all solid elements in the spare area 306.
Afterwards, in step S409, can first erasing instruction be carried out the number of times replacement and make zero, return step S403 then.At this, the flow process that Fig. 4 illustrated can finish when flash memory storage system 100 shutdown.
Base this, through mechanism shown in Figure 4, data field 304 and solid element in the spare area 306 are used fifty-fifty, and then prolong the life-span of flash memory storage system 100.
What deserves to be mentioned is, be to determine whether carrying out the solid element exchange between data field 304 and the spare area 306 with the number of times of carrying out erasing instruction in exemplary embodiment shown in Figure 4.Yet; In another embodiment of the present invention; The data of storing considering possibly produce mistake (this also be called read interference (read disturb)) because of repeatedly being read; Also comprise whether the number of times that the solid element of judgement in data field 304 is read (for example on average reads interference startup value above one the opportunity of above-mentioned startup solid element exchange; This on average reads and disturbs the startup value is to be set at 5000), if surpassing on average to read, the number of times that arbitrary solid element is read in the data field 304 disturbs the startup value, then the solid element in this solid element and the spare area 306 is carried out above-mentioned solid element exchanger.
Please refer again to Fig. 3 A, solid element 310-(the P+1)~310-(N) in replacing district 330 substitutes solid element.For example, flash memory chip 130 can be reserved 4% physical blocks and uses as changing when dispatching from the factory.That is to say that when the physical blocks in the memory block 320 was damaged, the physical blocks of reserving in replacing district 330 can be in order to replacing damaged physical blocks (that is, bad physical blocks (badblock)).Therefore, if replace when still having available physical blocks in the district 330, if the physical blocks damage takes place, memory management module 110b can extract the physical blocks that available physical blocks is changed damage from replace district 330.If when no available physical blocks and generation physical blocks were damaged in the replacement district 330, flash memory storage system 100 will can't be re-used by declaration.Particularly, in this exemplary embodiment, the number that belongs to the physical blocks that replaces district 330 can be above 2000.
What deserves to be mentioned is,, therefore can't use the solid element that belongs to replacement district 330 in the running in general writing and wipe as stated because the physical blocks that replaces in the district 330 is the physical blocks that is used to replace damage.Therefore, in exemplary embodiment of the present invention, memory management module 110b can replace solid element (the good physical unit) exchange of carrying out between district 330 and the spare area 306 well, and then makes the physical blocks that replaces in the district 330 also have an opportunity to be used.
Fig. 5 is the process flow diagram of one exemplary embodiment illustrate performed solid element exchange between spare area 306 and replacement district 330 according to the present invention.
Please with reference to Fig. 5, when flash memory storage system 100 starts, at first memory management module 110b can set replacement district average abrasion startup value in step S501.Replacing district's average abrasion startup value is the frequency that representative starts the solid element exchange that replaces between district 330 and the spare area 306; It is bigger wherein to replace district's average abrasion startup value; The frequency that starts the solid element exchange is lower; Otherwise it is littler to replace district's average abrasion startup value, and the frequency that starts the solid element exchange is higher.User (for example, the manufacturer of storage system) can be according to the quality of employed flash memory and the effect of desiring to reach average abrasion set up on their own and replace district's average abrasion startup value.In this exemplary embodiment, replacing district's average abrasion startup value is to be set at 1000.
In step S503, flash memory control 110 can be awaited orders and when arbitrary solid element was wiped free of, memory management module 110b can count second erasing instruction and carry out number of times.For example, memory management module 110b can add 1 with second erasing instruction execution number of times.
Afterwards, memory management module 110b can judge that whether second erasing instruction execution number of times is greater than replacing district's average abrasion startup value in step S505.If in step S505, judge when second erasing instruction is carried out number of times greater than replacement district average abrasion startup value, then in step S507, can carry out the solid element exchange.Specifically; Memory management module 110b can extract a solid element (S507-1) randomly from replace district 330 in step S507; And from spare area 306, extract a solid element (S507-3) randomly, the solid element that will from spare area 306, be extracted then is associated as the solid element that replaces district 330 (S507-5) and will from replace district 330, be extracted and is associated as spare area 306 (S507-7).That is to say; After execution in step S507-5 and S507-7; The solid element that from replace district 330, is extracted can logically belong to spare area 306; And the solid element that from spare area 306, is extracted can logically belong to replacement district 330, accomplishes the solid element that replaces between district 330 and the spare area 306 thus and exchanges.
For example, if when carrying out the physical blocks exchange, from replace district 330, extract solid element 310-(P+1), and from spare area 306, extract solid element 310-(P).Then, solid element 310-(P+1) can be associated as spare area 306, and solid element 310-(P) can be associated as replacement district 330.
What deserves to be mentioned is, be from replace district 330 and spare area 306, to select the solid element that exchanges with at random mode in this exemplary embodiment.Yet; In another exemplary embodiment of the present invention; Memory management module 110b also can write down the erasing times of each solid element, and be chosen in replace erasing times is lower in the district 330 solid element and in spare area 306 the higher solid element of erasing times exchange.That is to say that the solid element in the spare area 306 can be divided into the solid element and the low solid element of wiping that height is wiped, the wherein high solid element of wiping can be used as the solid element that carries out the solid element exchange.
Afterwards, in step S509, can second erasing instruction be carried out the number of times replacement and make zero, return step S503 then.At this, the flow process that Fig. 5 illustrated can finish when flash memory storage system 100 shutdown.
In exemplary embodiment of the present invention, memory management module 110b starts spare area 306 and replaces the solid element exchange between the district 330 through the second erasing instruction number of times, yet the invention is not restricted to this.In another exemplary embodiment of the present invention; Memory management module 110b also can write down the erasing times of each solid element; And when the difference of the average erasing times of data field 304 and spare area 306 solid elements and the average erasing times of the solid element that replaces district 330 surpasses a difference threshold value or when the difference of the average erasing times of spare area 306 solid elements and the average erasing times of the solid element that replaces district 330 surpasses a difference threshold value, then memory management module 110b can carry out spare area 306 and replace the solid element of distinguishing between 330 and exchange.Similarly, user (for example, the manufacturer of storage system) can be according to the quality of employed flash memory and the effect of desiring to reach average abrasion set up the difference threshold value on their own.In this exemplary embodiment, the difference threshold value is to be set at 100.
In addition, in the present invention's one exemplary embodiment, memory management module 110b can set up and safeguard that one replaces solid element table (not illustrating) and manages the solid element that replaces in the district 330.That is to say that memory management module 110b can use replacement solid element table to write down the solid element that belongs to replacement district 330.
In sum; The present invention carries out the solid element exchange between the data field of flash memory chip and spare area; And between the replacement district of flash memory chip and spare area, carry out the solid element exchange; Therefore the use meeting of the physical blocks of flash memory chip is more average, and then can significantly prolong the life-span of flash memory storage system.
Though the present invention with embodiment openly as above; Right its is not that those skilled in the art are not breaking away from the spirit and scope of the present invention in order to qualification the present invention; When doing a little change and retouching, so protection scope of the present invention is as the criterion when looking the appended claims person of defining.